Has base BMU code but sends dummy temperature and voltage readings to test CAN

Dependencies:   CUER_CAN DS1820 LTC2943 LTC6804 mbed

Fork of BMS_BMUCore_Max by CUER

Committer:
DasSidG
Date:
Sun Jul 02 11:25:37 2017 +0000
Revision:
15:e901aff1f5b3
Parent:
12:fa9b1a459e47
Added temperature probe initialization

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lcockerton62 1:51477fe4851b 1 /*
lcockerton62 1:51477fe4851b 2 * Code for identifying address and temperature of DS1820 1-Wire Thermometers by Maxim
lcockerton62 1:51477fe4851b 3 * Uses the DS1820 library written by Michael Hagberg and Fernando Caamaño, with some slight modifications
lcockerton62 1:51477fe4851b 4 * Currently tested using DS18S20 1-Wire Thermometers in an array, parasite power yet to be tested
lcockerton62 1:51477fe4851b 5 */
lcockerton62 1:51477fe4851b 6 #include "Temperature.h"
lcockerton62 1:51477fe4851b 7
lcockerton62 1:51477fe4851b 8 DS1820* probe[MAX_PROBES];
lcockerton62 1:51477fe4851b 9 int devices_found = 0;
lcockerton62 1:51477fe4851b 10
lcockerton62 1:51477fe4851b 11 void temperature_init()
lcockerton62 1:51477fe4851b 12 {
DasSidG 12:fa9b1a459e47 13 DigitalOut isotherm_12V_pin(ISOTHERM_12V_PIN);
DasSidG 12:fa9b1a459e47 14 isotherm_12V_pin = 1;
lcockerton62 1:51477fe4851b 15 int i;
lcockerton62 1:51477fe4851b 16 int address_byte_count;
lcockerton62 1:51477fe4851b 17 // Initialize the probe array to DS1820 objects
lcockerton62 1:51477fe4851b 18 for (i = 0; i < MAX_PROBES; i++)
lcockerton62 1:51477fe4851b 19 probe[i] = new DS1820(DATA_PIN, PARASITE_PIN);
lcockerton62 1:51477fe4851b 20 // Initialize global state variables
lcockerton62 1:51477fe4851b 21 probe[0]->search_ROM_setup();
lcockerton62 1:51477fe4851b 22 // Loop to find all devices on the data line
lcockerton62 1:51477fe4851b 23 while (probe[devices_found]->search_ROM() and devices_found<MAX_PROBES-1)
lcockerton62 1:51477fe4851b 24 devices_found++;
lcockerton62 1:51477fe4851b 25 // If maximum number of probes are found,
lcockerton62 1:51477fe4851b 26 // bump the counter to include the last array entry
lcockerton62 1:51477fe4851b 27 if (probe[devices_found]->ROM[0] != 0xFF)
lcockerton62 1:51477fe4851b 28 devices_found++;
lcockerton62 1:51477fe4851b 29
lcockerton62 1:51477fe4851b 30 if (devices_found==0)
lcockerton62 1:51477fe4851b 31 printf("No devices found");
lcockerton62 1:51477fe4851b 32 else {
lcockerton62 1:51477fe4851b 33 printf("\n%d device(s) found!\r\n\n" ,devices_found);
lcockerton62 1:51477fe4851b 34 for (i=0; i<devices_found; i++) {
lcockerton62 1:51477fe4851b 35 printf("Device %d address is: \r\n", i+1);
lcockerton62 1:51477fe4851b 36 for(address_byte_count=0; address_byte_count<8; address_byte_count++) {
lcockerton62 1:51477fe4851b 37 printf("0x%02x", probe[i]->ROM[address_byte_count]);
lcockerton62 1:51477fe4851b 38 if(address_byte_count == 7) printf("\r\n\n");
lcockerton62 1:51477fe4851b 39 else printf(", ");
lcockerton62 1:51477fe4851b 40 }
lcockerton62 1:51477fe4851b 41 }
lcockerton62 1:51477fe4851b 42 }
lcockerton62 1:51477fe4851b 43 }
lcockerton62 1:51477fe4851b 44