Forum Replies Created
-
AuthorPosts
-
pinkstondMember
😉
Well, commenting out all the interrupt lines made it stop flashing.. Inaccurate reads now… I keep trying commenting some out and not others and see what I can come up with. Might also do some googling on similar issues with the onewire lib. I think in the mean time I’ll get an analog sensor on order.
pinkstondMemberNope. Its not the string, it’s the part of the sensor reading. I did have another analog sensor hooked up and was displaying it on the screen the same way, and it never skipped until I added the code under the getTemp function. I’ve tried to narrow down what part of that is doing it with no luck.
I added
tv.print(0, 70, "foo");
and commented out these two
tv.print(0, 80, temp);
dtostrf(tmp, 1, 1, temp);and foo is still blinking from what I am guessing is the part where it’s pulling the info from the sensor.
pinkstondMemberAdded and arranged things as you said to, and it’s back to it’s original behavior. The temp shows up fine, but when the temp updates it jumps across the screen. It’s almost like the VBI isn’t enough time for the code to run? Or the VBI isn’t happening?
I drove around town and tried to find a analog temp sensor since I’ve lost so much time on this, but was unable to find one locally.
I think I might just find an analog one online, but it would be nice to find the solution to this issue to possibly help others in the same position in the future. I just don’t want to use up more of your time.
pinkstondMemberI’m sorry, I’m really new to this and sometimes when I work days on a simple issue like that I get too lazy and quick to get an answer. The code below I stripped out the information that is not relevant to this issue and organized it the best I can.
#include
#include
#include
OneWire ds1(10);
TVout tv;
unsigned char x,y;
unsigned char originx = 5;
unsigned char originy = 80;
unsigned char plotx = originx;
unsigned char ploty = 40;
char temp[10];
void setup() {
tv.begin(NTSC, 120, 96);
initOverlay();
tv.select_font(font6x8);
tv.fill(0);
tv.set_vbi_hook(&getTemp);
}
void initOverlay() {
TCCR1A = 0;
TCCR1B = _BV(CS10);
TIMSK1 |= _BV(ICIE1);
EIMSK = _BV(INT0);
EICRA = _BV(ISC11);
}
ISR(INT0_vect) {
display.scanLine = 0;
}
void loop() {
tv.print(23, 80, "*F");
tv.delay_frame(1);
dspData(); //Display the recieved temp from getTemp
}
//Get the temp from the sensor.
void getTemp() {
byte data1[12];
byte addr1[8];
if ( !ds1.search(addr1)) {
}
ds1.reset();
ds1.select(addr1);
ds1.write(0x44,1);
byte present = ds1.reset();
ds1.select(addr1);
ds1.write(0xBE);
for (int p = 0; p < 9; p++) {
data1[p] = ds1.read();
}
ds1.reset_search();
float MSB = ((data1[1] << 8));
float LSB = (data1[0]);
float tempRead = (MSB + LSB);
float tmp = tempRead / 16 * 1.8 + 32 - 5; //Convert Celsius to Fahrenheit
dtostrf(tmp, 1, 1, temp); //Convert the float to a string so it can be displayed properly
}
//Display the temp
void dspData() {
tv.print(0, 80, temp);
}I didn’t know if I needed to call the getTemp function in the loop, but I have tried both ways. With the code above I end up getting this on the video output:
pinkstondMemberI’ve also tried this method:
Ignore the sloppiness, and the noobness. Lots of copy and pasting and moving stuff around to see if it’ll work right.
#include
#include
#include
#define W 136
#define H 96
OneWire ds1(10);
TVout tv;
unsigned char x,y;
unsigned char originx = 5;
unsigned char originy = 80;
unsigned char plotx = originx;
unsigned char ploty = 40;
char emf[10];
char temp[4];
float val;
float tmp;
unsigned short avg;
char inVBI;
void setup() {
tv.set_vbi_hook(&setVBIFlag);
tv.begin(NTSC, W, H);
initOverlay();
tv.select_font(font6x8);
tv.fill(0);
Serial.begin(9600);
}
void initOverlay() {
TCCR1A = 0;
TCCR1B = _BV(CS10);
TIMSK1 |= _BV(ICIE1);
EIMSK = _BV(INT0);
EICRA = _BV(ISC11);
}
ISR(INT0_vect) {
display.scanLine = 0;
}
void setVBIFlag() {
inVBI = true;
}
void loop() {
if (inVBI) {
delay(2000);
byte data1[3];
byte addr1[0];
if ( !ds1.search(addr1)) {
//no more sensors on chain, reset search
// ds1.reset_search();
// return -1000;
}
ds1.reset();
ds1.select(addr1);
ds1.write(0x44,1); // start conversion, with parasite power on at the end
byte present = ds1.reset();
ds1.select(addr1);
ds1.write(0xBE); // Read Scratchpad
//No Prob Here
for (int p = 0; p < 9; p++) { // we need 9 bytes
data1[p] = ds1.read();
}
ds1.reset_search();
float MSB = ((data1[1] << 8));
float LSB = (data1[0]);
float tempRead = (MSB + LSB); //using two's compliment
float tmp = tempRead / 16 * 1.8 + 32;
dtostrf(tmp, 1, 1, temp);
int ary1[300];
for(int b = 0; b < 300; ++b) {
ary1 = analogRead(1);
avg += ary1;
}
val = avg / 300;
val = constrain(val, 0, 100);
val = map(val, 0, 100, 0, 255);
val = val *.1;
dtostrf(val, 1, 1, emf);
avg = 0;
inVBI = false;
}
tv.print(0, 89, "EMF");
tv.print(20, 89, emf);
tv.print(24, 80, "*F");
tv.print(0, 80, temp);
}
pinkstondMemberHrm, I’m sure I am doing this all wrong… But when ever I did what you said I don’t get anything displayed at all. Right after it uploads I get a big block of squiggly lines that fill the screen for a second and then nothing..
pinkstondMemberSorry, should have mentioned that. It is currently on D10.
-
AuthorPosts