Serial in from Picaxe?

I'm having some trouble...I want to read six bytes of data sent from a Picaxe at 2400 baud. Eventually I need to set up an interrupt to call a subroutine when the data comes in, but for now just getting the data would be great. I see you have to open a channel with serial.begin, but I'm getting a weird error, and I'd like to be able to monitor what's going on with serial.print, and it seems that on the Decimilia I'm limited to one serial channel - is this the case?

(I don't have my system here, and I can't remember what the exact error was - the compiler had an issue with my serial.begin statement, but it referenced something later on in my code - something about the begin statement being out of scope?)

You would want to look at using the SOFTWARE SERIAL routines to use a DIGITAL pin for PICAXE communication. That way you still have the regular serial port/uart/PC as a monitor to see what's happening.

You would want to look at using the SOFTWARE SERIAL routines to use a DIGITAL pin for PICAXE communication

But the SoftwareSerial routines are synchronous - they wouldn't work with interrupt-driven Rx.

What you could try is to use the standard serial library at 2400bps for PicAxe comms, in which case, buffering is automatic, and then use softserial for onward transmission.

Yes, the Diecimilia is limited to one hardware UART.

You're telling me the Arduino can't do something that the BX24, Basic Stamp & even the lowly Picaxe 08M can do?!? Do I have to find another uC??

You're telling me the Arduino can't do something that the BX24, Basic Stamp & even the lowly Picaxe 08M can do?!? Do I have to find another uC??

I don't think that is the case. The standard Arduino has one built in serial port using pins 0 & 1. These use internal interrupts to monitor incoming serial data and makes a statement serial.available true. It's up to your code to monitor this flag and store and count the six characters you are expecting and take action. There are also software serial libraries available so that you can have additional serial ports for your sketch.

Perhaps if you post your code there can be better help provided for you?

Lefty

You're telling me the Arduino can't do something that the BX24, Basic Stamp & even the lowly Picaxe 08M can do?!?

No, I don't think so.

Re-read what I said.

As Lefty said, tell us what you're trying to do, and we'll be able to help.

BX24 and Basic Stamp both execute interpreted code very slowly.
I guess the Arduino doesn't do that.
Dunno about the PicAxe.

Ok, thanks for the help...I've also been looking through the references and I see the difference between hardware & software serial, though at the moment I don't have any info on 2400 baud operation. I'll keep poking around a bit, maybe someone has posted code with the right values...

Basically, the Picaxe spits out 6 bytes every once in a while, like so:

serout 4, N2400, (128, b1, b2, b3, b4, b5)

So I can use the software routines to send data to the terminal, and use the hardware RX pin for the Picaxe? I can just poll serial.available(), a lot easier than figuring out how to use interrupts. :slight_smile: As you can tell, I'm kind of new at this stuff...

That should work. Both the hardware serial and software serial use a setup command to define the baud rate you want to use, that is usually placed in the setup portion of one's sketch.

I started with Picaxe and really enjoyed them, but I think you will find in time that the Arduino has much higher capability, you just have to master C/C++ and dig around a lot for libraries and code fragments when trying something you haven't coded before.

Lefty