Picaxe serial connect, send data

unigamer

Member
Ultimately I would like to send data to and from a Picaxe chip through Matlab.

Code:
main:

SERRXD [1000],("ABC"),#b1,#b0
SerTxd(#b1,#b0,lf,cr)

goto main
That's the little test program I am using just now. It works when I am using the terminal (built into the programming editor) but it doesn't work properly with either Matlab or Termite (a serial terminal).

I can receive data with both Matlab and Termite but I cannot send it. Sending works with programming editor terminal only when 5ms delay option is used (if it is not ticked then I can't send data). This makes me think the 5ms delay is necessary for Picaxe communication. However, other people have managed to connect Picaxe's to computers so I suspect I might be doing something wrong!

Jonathan

Edit: it appears that if I remove the qualifier I can send text with Termite but obviously I neeed a qualifier because it doesn't work correctly without one.
 
Last edited:

hippy

Ex-Staff (retired)
Firstly remove the timeout as that just makes things more complex.

Then, to receive "("ABC"),#b0,#b1" you need to send "ABC", then some digits ( for b0 ), a non-digit to indicate the end of that data, some more digits ( for b1 ), and one non-digit to indicate the end of that data.

If it works under Programming Editor Terminal, it should work in other cases. If it doesn't then there may be an issue in configuring the software used, the wrong COM port selected, wrong baud rate, wrong handshaking, or the data is being sent too quickly.

I'd also change the SERTXD "lf,cr" to CR then LF as that could cause problems for some software.
 

unigamer

Member
Thanks for the cr/lr advice, that did make it behave better (in the terminal). Unfortunately the code still will not work with Termite, I am fairly confident that I have the settings correct (I can receive data and I have used Termite for embedded linux stuff without a problem)


My code is now:

Code:
main:

SERRXD("ABC"),#b1,#b0


SerTxd(#b1,#b0,cr,lf)



goto main
It works in the terminal when 5ms delay is ticked but otherwise doesn't. What is the standard way to workaround the delays Picaxe has? In matlab should I have a pause between every character sent?

terminal.PNGtermite.PNG
 

hippy

Ex-Staff (retired)
It works in the terminal when 5ms delay is ticked but otherwise doesn't ... In matlab should I have a pause between every character sent?
That would seem to be a solution.

Less brute-force; you could send the qualifier, pause, first data, pause, second data. You might have to experiment with where the pauses are, between each character or after a set of characters, and just putting each on a separate line in the code may remove the need for pauses. Changing to two stop bits will likely help things.
 

unigamer

Member
6 hours of serial pain later (I really need to improve my debugging skills!)...

I reduced the speed to 1200 (by using serin and serout) and it's working with termite now. Speed is not critical for my application so a low baud rate is not a problem.

I will reduce the number of stopbits too.


Thanks for the assistance, you've helped me out many times before and your posts on this forum have really helped me.


Edit: Unfortunately I still can't send commands with Matlab, only receive them. But that is probably an issue with matlab rather than the picaxe.
 
Last edited:
Top