I'm trying to use a 20X2 as an I2C slave to a Mindstorms NXT. I have a Sirf III GPS attached to the Picaxe, which reads the time into six bytes, puts them in the scratchpad and sends them to the computer. I'm hoping to get the the Picaxe and GPS to act as a super accurate RTC. I also have a pin on the Picaxe attached to pin 1 on the NXT with a 2.2K resistor to simulate a touch sensor. Since the Picaxe spends quite a bit of time waiting for data from the GPS, I have it signal the NXT when new data is available by pulling the pin low, and returning it to an input or high-Z state when it is hanging on the serin command.
However, it's not working . I tested it out with a single byte first, a value from a LDR. It would read onto the NXT screen just fine. However, when I switched over to the GPS, the NXT would lose the connection with the Picaxe after the first read and stop displaying any values. By restarting the whole setup, I could get it to work again. Just restarting the Picaxe or NXT wouldn't have any effect (I think I used the right one, right Dippy? Or should it be affect... ).
So, I attached a potentiometer to the Picaxe as well and tried just reading the LDR and pot. Still no luck. So, I tried the single byte program again, no luck! Somehow something got messed up...
So, it would seem as if reading values into the NXT by way of Picaxe doesn't work for me. Mattallen37 has had luck reading multiple ADC values into the Picaxe and passing them onto the NXT but I didn't have any luck even when I tried his programs. Technical also said that he had success using a Picaxe 20X2 as a NXT slave.
The code below reads one byte and makes it available to the NXT in the scratchpad. This code worked in the beginning, but not anymore.
This code below is supposed to read the time from a GPS into the scratchpad. It outputs the time just fine to the computer, but the NXT doesn't read it properly, it just displays zeros.
Can anyone confirm if I'm doing something wrong on the Picaxe side of things? I think I could debug my NXT program, but my understanding of the scratchpad and all associated commands is still a bit weak. I attached a screenshot of the program running on the NXT.
However, it's not working . I tested it out with a single byte first, a value from a LDR. It would read onto the NXT screen just fine. However, when I switched over to the GPS, the NXT would lose the connection with the Picaxe after the first read and stop displaying any values. By restarting the whole setup, I could get it to work again. Just restarting the Picaxe or NXT wouldn't have any effect (I think I used the right one, right Dippy? Or should it be affect... ).
So, I attached a potentiometer to the Picaxe as well and tried just reading the LDR and pot. Still no luck. So, I tried the single byte program again, no luck! Somehow something got messed up...
So, it would seem as if reading values into the NXT by way of Picaxe doesn't work for me. Mattallen37 has had luck reading multiple ADC values into the Picaxe and passing them onto the NXT but I didn't have any luck even when I tried his programs. Technical also said that he had success using a Picaxe 20X2 as a NXT slave.
The code below reads one byte and makes it available to the NXT in the scratchpad. This code worked in the beginning, but not anymore.
Code:
#no_table 'no need to extend download times...
pullup %10100000 'activate internal pullups to minimize part count...
hi2csetup i2cslave,80 'setup as I2C slave
main: readadc B.6,b0 'read LDR
put 0,b0 'put LDR value in scratchpad
sertxd (#b0,CR,LF) 'send it to computer
low B.0
pause 800
input B.0
goto main
Code:
#no_table
pullup %10100000
hi2csetup i2cslave,80
main: serin C.7,T4800_8,("GGA,"),b0,b1,b2,b3,b4,b5
let b0=53
put 0,b0,b1,b2,b3,b4,b5
sertxd (b0,b1,b2,b3,b4,b5,CR,LF)
low B.0
pause 600
input B.0
pause 10
goto main