New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using INA in Teensy 3.x boards #30
Comments
Does one of the example programs work when using the standard “Wire.h” library?
…-Arnd.
From: AluminioVanadio <notifications@github.com>
Sent: 14 October 2018 18:10
To: SV-Zanshin/INA <INA@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>
Subject: [SV-Zanshin/INA] Using INA in Teensy 3.x boards (#30)
I have been unable tu use the library in a teensy 3.2 board, I changed the include from Wire.h to i2c_t3.h. It compiles but at least the example file does not detect an INA226. I can detect it using a scanner sketch which runs OK in teensy.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#30> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AWfRxAC0EM6YSpWDDsSHJfJnkbfC4u0nks5uk2_2gaJpZM4XbOe0> . <https://github.com/notifications/beacon/AWfRxK26H6lBJepHmfcwn5Xf7-bFg_rfks5uk2_2gaJpZM4XbOe0.gif>
|
Hi, Compiling 'BackgroundRead' for 'Teensy 3.2 / 3.1' BackgroundRead.ino: 71:5: error: expected constructor, destructor, or type conversion before '(' token BackgroundRead.ino: In function void setup() BackgroundRead.ino: 95:3: error: 'PCIFR' was not declared in this scope BackgroundRead.ino: 96:3: error: 'PCICR' was not declared in this scope Using Visual Studio IDE. Compiles OK selecting an Arduino Leonardo. It looks like port manupulation in teensy is different. Also I don not hace interrupts pins hooked up. SDA and SCL pins are correctly mapped by Wire.h looking at the scope. |
Hello,
Any code that revolves around interrupts and interrupt handling is going to be difficult to get running on all processors. The programs were developed and tested on Atmega 8 bit boards so I’m not surprised that things like the “PCIFR” and “PCICR” buffers don’t match up.
But the base library should work, and the “DisplayReadings” program is pretty basic and doesn’t use interrupts so it should work. The EEPROM handling looks to be same as well, which was a problem for Esplore devices.
Could you try to add the following green lines in the library code at Line 193 of the “INA.cpp”?
Serial.print(“Max Devices is “);Serial.println(maxDevices);
Serial.print(“Found device at “);Serial.println(deviceAddress);
if (Wire.endTransmission() == 0 && _DeviceCount < maxDevices) // If no error and EEPROM has space //
{ // //
originalRegister = readWord(INA_CONFIGURATION_REGISTER,deviceAddress);// Save original register settings //
writeWord(INA_CONFIGURATION_REGISTER,INA_RESET_DEVICE,deviceAddress); // Forces INAs to reset //
tempRegister = readWord(INA_CONFIGURATION_REGISTER,deviceAddress);// Read the newly reset register //
My guess is that the “EEPROM.length()” function might not be working correctly for that device and we would need to add a device-specific “#ifdef” to the code.
…-Arnd.
From: AluminioVanadio <notifications@github.com>
Sent: 14 October 2018 22:27
To: SV-Zanshin/INA <INA@noreply.github.com>
Cc: Arnd <zanshin_github@sv-zanshin.com>; Comment <comment@noreply.github.com>
Subject: Re: [SV-Zanshin/INA] Using INA in Teensy 3.x boards (#30)
Hi,
I tried BackgroundRead also, with the library freshly installed and does not compile :
Compiling 'BackgroundRead' for 'Teensy 3.2 / 3.1'
BackgroundRead.ino: 71:5: error: expected constructor, destructor, or type conversion before '(' token
ISR (PCINT0_vect) { \ handle pin change interrupt D8
BackgroundRead.ino: In function void setup()
Error compiling project sources
Build failed for project 'BackgroundRead'
BackgroundRead.ino: 95:3: error: 'PCIFR' was not declared in this scope
PCIFR |= bit (digitalPinToPCICRbit(INA_ALERT_PIN)); \ clear any outstanding interrupt
BackgroundRead.ino: 96:3: error: 'PCICR' was not declared in this scope
PCICR |= bit (digitalPinToPCICRbit(INA_ALERT_PIN)); \ enable interrupt for the group
Using Visual Studio IDE.
Compiles OK selecting an Arduino Leonardo. It looks like port manupulation in teensy is different. Also I don not hace interrupts pins hooked up.
DisplayReadings compiles but it does not detect the INA226.
No INA device found, retrying in 10s...
No INA device found, retrying in 10s...
No INA device found, retrying in 10s...
SDA and SCL pins are correctly mapped by Wire.h looking at the scope.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#30 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AWfRxA-HiScRXh0b24r89XJm1r3KNF1qks5uk6wkgaJpZM4XbOe0> . <https://github.com/notifications/beacon/AWfRxP9xtOZiNBoDJebvqtpuTbxQbOgpks5uk6wkgaJpZM4XbOe0.gif>
|
Hello Arnd. |
I added some #ifdefs to support the TEENSY boards to the code, that should work for your implementation now. |
Line 188 of the modified INA.cpp file has the variable type declaration missing: |
That is quite odd. Did you get a compiler error with the missing type declaration or did you notice it yourself? I am asking because perhaps the “CORE_TEENSY” isn’t the correct variable to check.
From: AluminioVanadio <notifications@github.com>
Sent: 17 October 2018 02:13
To: SV-Zanshin/INA <INA@noreply.github.com>
Cc: Arnd <zanshin_github@sv-zanshin.com>; State change <state_change@noreply.github.com>
Subject: Re: [SV-Zanshin/INA] Using INA in Teensy 3.x boards (#30)
Line 188 of the modified has the variable type declaration missing:
uint8_t maxDevices = 2048 / sizeof(inaEE);
But stiil doesn't work in teensy 3.2, unless I assign maxDevices a fixed value.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub <#30 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AWfRxPaAo6c5CU5WO0-IlwG70_tn3oVnks5uloQTgaJpZM4XbOe0> . <https://github.com/notifications/beacon/AWfRxKVInOAnVXFMP9b2kZkuC0pnhQMLks5uloQTgaJpZM4XbOe0.gif>
|
Hi, INA.cpp: 188:3: error: 'maxDevices' was not declared in this scope Looking at i2c_t3, made for teensy boards, they use the following definitions for detecting all board models: #include "i2c_t3.h" |
The compiler error would seem to indicate that the branch in the #ifdef was taken correctly, but I've added the directives you listed above to the code and fixed the way that the variable "maxDevices" is declared. Can you check to see if the current version works correctly? |
Hi, |
Thanks for pointing out that error - I should start using those bigger boards to broaden my horizons from the much more resource-restricted Atmel processors. |
I have been unable tu use the library in a teensy 3.2 board, I changed the include from Wire.h to i2c_t3.h. It compiles but at least the example file does not detect an INA226. I can detect it using a scanner sketch which runs OK in teensy.
The text was updated successfully, but these errors were encountered: