Cell voltages fork (SoC)

Dependencies:   CUER_CAN CUER_DS1820 LTC2943 LTC6804 mbed PowerControl

Committer:
maxv008
Date:
Sun Jul 02 17:00:44 2017 +0000
Revision:
20:a1a1bfc938da
Parent:
18:521ffdd724f3
Child:
21:d461d58e70fc
Completely working CAN read and write (currently in write mode for bms) with live voltage/temp data. Form that is usable in final versions

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];
maxv008 18:521ffdd724f3 9 int devices_found;
lcockerton62 1:51477fe4851b 10
lcockerton62 1:51477fe4851b 11 void temperature_init()
lcockerton62 1:51477fe4851b 12 {
maxv008 20:a1a1bfc938da 13 //DigitalOut isotherm_12V_pin(ISOTHERM_12V_PIN);
maxv008 20:a1a1bfc938da 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