hello,
I'm trying to use orangkucing's teensy3 fork on a teensy3.5, IDE1.8.7, win10
I eventually got it running, but interrupts are really all over the place.
Since I cannot open issues on his fork and considering that the core of the work is yours, I thought I'd open an issue here, hope it's OK.
Now, to clarify, I'm trying the analogComp_enableInterrupt.ino with:
Testing the first analog comparator CMP0 with:
AIN- coming from a pot I had lying around (+ 3V3, - AGND, output to CMP0_IN0-pin13, or more conventiently CMP0_IN2-pin35 A16)
AIN+ from the relevant DAC1_OUT-pin67 aka A22 which for the test I drive at #700 using 10bit resolution
Testing it turning the pot left and right and looking for when the led lits, it was obvious that something was wrong. LED was flashing at different points in the pot, looked like it shifted back and forth, so I just added a Serial.println to check the values of AIN1 and AIN0 when it triggers.
AIN1: 182, AIN0: 700 AIN1: 264, AIN0: 701 AIN1: 193, AIN0: 701 AIN1: 221, AIN0: 701 AIN1: 165, AIN0: 701 AIN1: 271, AIN0: 701 AIN1: 164, AIN0: 701 AIN1: 300, AIN0: 701 AIN1: 188, AIN0: 701 AIN1: 206, AIN0: 701 AIN1: 180, AIN0: 701 AIN1: 228, AIN0: 701 AIN1: 219, AIN0: 701 AIN1: 216, AIN0: 701 AIN1: 126, AIN0: 701 AIN1: 258, AIN0: 701 AIN1: 169, AIN0: 700 AIN1: 255, AIN0: 701 AIN1: 192, AIN0: 700 AIN1: 211, AIN0: 701 AIN1: 113, AIN0: 700
Lower values is when I was turning the pot down and higher when up, so seems to be a delay which I could possibly accept. BUT I do get some values jumping a bit more, see most are around 180-220 and occasionally a 271 and 300 a 258 etc.
System has to accurately monitor and stop a shaft rotating (via digital signals to two DD relays operating solenoids that control 100bar of hydraulic pressure rams going back and forth), I cannot afford more than 3-5 off (should convert to less than a degree rotation)
Actually and that's my second problem, I see the system triggering at values generally shifted from the AIN+ of 700 (approx 2.26V) as it AIN- is at around 200 (way under 1V!) Any idea why 2.26V reference get triggered with anything form 0.6V- 0.8V?
The code I'm using is simply yours with an extra debug print line:
`//include the library
#include "analogComp.h"
//global variables
const byte LED13 = 13; //set the output LED
boolean enableLed = false; //used to check if the interrupt has raised
//let's set up the hardware
void setup() {
pinMode(LED13, OUTPUT); //LED pin as output
pinMode(A22, OUTPUT); //the PORT DAC output set to a value...
analogWriteResolution(10); //10bit 1023 max
analogWrite(A22, 700);
//non inverting AIN+ = AIN0 = internal voltage reference
//inverting AIN- = AIN1 = analog input
analogComparator.setOn(AIN0, A22); //we instruct the lib to use voltages on the pins
analogComparator.enableInterrupt(changeStatus, CHANGE); //FALLING RISING CHANGE we set the interrupt and when it has to be raised
}
//main loop
void loop() {
if (enableLed) { //let's check if the analog comparator has raised the interrupt
Serial.println("AIN1: " + String(analogRead(A16)) + ", AIN0: " + String(analogRead(A22)));
//yes, so we do a little blink of the LED
digitalWrite(LED13, HIGH);
delay(50);
digitalWrite(LED13, LOW);
enableLed = false;
}
}
//interrupt to be raised by the analog comparator
void changeStatus() {
enableLed = true; //let's inform the main loop that the condition has been reached by the analog comparator
}`
Possible issues:
- COMP0 not happy to use an internally voltage reference (DAC1_OUT) although on all documentation I read it's meant to be acceptable solution.
- internal voltage not stable, well checked it with a half decent digital v/meter and it's stuck to 2.27V doesn't move
- current issues, unlikely as I drive the teensy from a stabilised 5A 5V supply and not the USB cable (chopped red out of the usb)
I wonder if you have any idea on what I'm doing wrong. I've spent a couple of days trying to get it running as I initially was wiring it all wrong (assumed pin11 to be A11 and was using DAC0 for CMP0 whereas it should be DAC1) and now that's running the results are rather disappointing.
BTW, I have the full system already running with a while loop for each shaft (got two to work with) BUT I need the processor to do other stuff as well and cannot afford the waiting. There's a MPC9250 sensor that needs to be polled all the time and mins and maxs of roll and accel recorded for further actions.
So it's either going to be teensy3 with interrupts or ESP32 with dual threading running both in parallel...
cheers
Vassilis
hello,
I'm trying to use orangkucing's teensy3 fork on a teensy3.5, IDE1.8.7, win10
I eventually got it running, but interrupts are really all over the place.
Since I cannot open issues on his fork and considering that the core of the work is yours, I thought I'd open an issue here, hope it's OK.
Now, to clarify, I'm trying the analogComp_enableInterrupt.ino with:
Testing the first analog comparator CMP0 with:
AIN- coming from a pot I had lying around (+ 3V3, - AGND, output to CMP0_IN0-pin13, or more conventiently CMP0_IN2-pin35 A16)
AIN+ from the relevant DAC1_OUT-pin67 aka A22 which for the test I drive at #700 using 10bit resolution
Testing it turning the pot left and right and looking for when the led lits, it was obvious that something was wrong. LED was flashing at different points in the pot, looked like it shifted back and forth, so I just added a Serial.println to check the values of AIN1 and AIN0 when it triggers.
AIN1: 182, AIN0: 700 AIN1: 264, AIN0: 701 AIN1: 193, AIN0: 701 AIN1: 221, AIN0: 701 AIN1: 165, AIN0: 701 AIN1: 271, AIN0: 701 AIN1: 164, AIN0: 701 AIN1: 300, AIN0: 701 AIN1: 188, AIN0: 701 AIN1: 206, AIN0: 701 AIN1: 180, AIN0: 701 AIN1: 228, AIN0: 701 AIN1: 219, AIN0: 701 AIN1: 216, AIN0: 701 AIN1: 126, AIN0: 701 AIN1: 258, AIN0: 701 AIN1: 169, AIN0: 700 AIN1: 255, AIN0: 701 AIN1: 192, AIN0: 700 AIN1: 211, AIN0: 701 AIN1: 113, AIN0: 700Lower values is when I was turning the pot down and higher when up, so seems to be a delay which I could possibly accept. BUT I do get some values jumping a bit more, see most are around 180-220 and occasionally a 271 and 300 a 258 etc.
System has to accurately monitor and stop a shaft rotating (via digital signals to two DD relays operating solenoids that control 100bar of hydraulic pressure rams going back and forth), I cannot afford more than 3-5 off (should convert to less than a degree rotation)
Actually and that's my second problem, I see the system triggering at values generally shifted from the AIN+ of 700 (approx 2.26V) as it AIN- is at around 200 (way under 1V!) Any idea why 2.26V reference get triggered with anything form 0.6V- 0.8V?
The code I'm using is simply yours with an extra debug print line:
`//include the library
#include "analogComp.h"
//global variables
const byte LED13 = 13; //set the output LED
boolean enableLed = false; //used to check if the interrupt has raised
//let's set up the hardware
void setup() {
pinMode(LED13, OUTPUT); //LED pin as output
pinMode(A22, OUTPUT); //the PORT DAC output set to a value...
analogWriteResolution(10); //10bit 1023 max
analogWrite(A22, 700);
//non inverting AIN+ = AIN0 = internal voltage reference
//inverting AIN- = AIN1 = analog input
analogComparator.setOn(AIN0, A22); //we instruct the lib to use voltages on the pins
analogComparator.enableInterrupt(changeStatus, CHANGE); //FALLING RISING CHANGE we set the interrupt and when it has to be raised
}
//main loop
void loop() {
if (enableLed) { //let's check if the analog comparator has raised the interrupt
Serial.println("AIN1: " + String(analogRead(A16)) + ", AIN0: " + String(analogRead(A22)));
//yes, so we do a little blink of the LED
digitalWrite(LED13, HIGH);
delay(50);
digitalWrite(LED13, LOW);
enableLed = false;
}
}
//interrupt to be raised by the analog comparator
void changeStatus() {
enableLed = true; //let's inform the main loop that the condition has been reached by the analog comparator
}`
Possible issues:
I wonder if you have any idea on what I'm doing wrong. I've spent a couple of days trying to get it running as I initially was wiring it all wrong (assumed pin11 to be A11 and was using DAC0 for CMP0 whereas it should be DAC1) and now that's running the results are rather disappointing.
BTW, I have the full system already running with a while loop for each shaft (got two to work with) BUT I need the processor to do other stuff as well and cannot afford the waiting. There's a MPC9250 sensor that needs to be polled all the time and mins and maxs of roll and accel recorded for further actions.
So it's either going to be teensy3 with interrupts or ESP32 with dual threading running both in parallel...
cheers
Vassilis