I’m using the following library on Electron running 0.7.0:
[https://github.com/jjuliano77/JJ_AD7794]
Following his 6 channel example, when I issue this command:
double junk = adc.read(0);
the electron fails to advance beyond
This is the code it calls:
//Experiment with reading all active channels, this may be the way I go in the future UNTESTED
void AD7794::read(float *buf, uint8_t bufSize)
{
uint8_t readingCnt = 0 ;
for(int i = 0; i < CHANNEL_COUNT; i++){
if(Channel[i].isEnabled){
if(readingCnt < bufSize){
buf[readingCnt] = read(i);
}else{
//buffer too small!
//Maybe return an error code?
}
readingCnt++;
}
}
}
/* read - The single channel version
Gets reading from a single channel. Right now it
is in volts (default scailing), but I may have it use
a scaling setting stored for each channel. I might also
just save that for a higher level hardware abstraction class.
*/
float AD7794::read(uint8_t ch)
{
//Lets the conversion result
uint32_t adcRaw = getReadingRaw(ch);
//Serial.print(adcRaw);
//Serial.print(' ');
float result;
if(ch == 6){ //Channel 6 is temperature, handle it differently 1.17 V internal Ref
return (((float)adcRaw / ADC_MAX_BP - 1) * 1.17); //Bipolar, not sure what mode for temp sensor
}
//And convert to Volts, note: no error checking
if(Channel[currentCh].isUnipolar){
result = (adcRaw * vRef) / (ADC_MAX_UP * Channel[currentCh].gain); //Unipolar formula
//Serial.print("unipolar");
}
else{
result = (((float)adcRaw / ADC_MAX_BP - 1) * vRef) / Channel[currentCh].gain; //Bipolar formula
//Serial.print("bipolar");
}
return result - Channel[currentCh].offset;
}
I know nothing about code
so I don’t know what the issue might be.
Any help is much appreciated.
As an aside, I’m really interested in learning more about C++. My background is in hardware, but I’d like to be able to write firmware too. How can i get a crash course?