Pages: [1]   Go Down
Author Topic: Serial in from Picaxe?  (Read 1278 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  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?)
Logged

Cumming, GA
Offline Offline
Edison Member
*
Karma: 18
Posts: 1628
Ultimate DIY: Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 241
Posts: 24480
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
« Last Edit: June 04, 2009, 09:12:13 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 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??

Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 332
Posts: 16568
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 241
Posts: 24480
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 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. smiley As you can tell, I'm kind of new at this stuff...
« Last Edit: June 04, 2009, 05:18:14 pm by Crow » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 332
Posts: 16568
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Pages: [1]   Go Up
Jump to: