serial serin serout with the programming cable? 18x

phillyk

New Member
Hi, I am trying to decide how to program my Picaxe as a computer controlled Motor driver. I am using an 18x (with the power project board)
I want to have a simple program interect via serial & the existing cable.
I have a minorly complex algorithm written that allows the motors to interact with values hard set.
I have tested my code with the "simulate" mode. But when I run my code with a terminal session, I don't know if my data's getting in & I don't always get ANY data out. It seems that for whatever reason my code crash's & reset's rather than recieve data.
my code is below :
l2: 'l2 is serin point & main program
high 2
sertxd ("Gimme Data x,y",#b4,#b5)
sertxd (10,13)
serin 3,N4800,("xy"),b4,b5
low 2
pause 1000
goto l2

If what I am wanting to do, use a picaxe as CNC motor controll is not possible, Let me know. but I don't see why not. all the doc's hint that it should serial interface quite well. Or do i HAVE to re-wire it & not use the programming cable? the Documentation isn't clear about that. I ahve looked at the 2nd PDF page 140-147 numerous times & also page 42 - 45 of another PDF. Feel free to try to email me with any help, or request for more info.
 

hippy

Ex-Staff (retired)
Staff member
serin 3,N4800,("xy"),b4,b5

There is no Input Pin 3 on a PICAXE-18X. I guess you are using "3" to be "leg 3", Serial In as used for downloading - unfortunately that won't work with an 18X and you will see resets and all sorts of peculiar failures.

What you need to do is duplicate the 10K/22K download interface but take the 22K to an Input Pin ( leg 1, 15, 16, 17 or 18, Input Pins 2, 6, 7, 0 and 1 respectively ). The output to the download interface ( used by SERTXD ) can also go to thie output for this serial interface.

However, here's an easy alternative way to do it ...

Code:
                                              .-----------------.
                               ___            |                 |
                          .---|___|---------->| Input Pin       |
                          |    22K            |                 |
TX to PC    O<------------|-------------------| Serial Out      |
                          |    ___            |                 |
RX from PC  O---------.---^---|___|---.------>| Serial In       |
                     .|.       22K    |       |                 |
0V          O---.    | |              O       `-----------------'
                |    |_| 22K          O Link
               _|_   _|_             _|_
Open that link when you want to download, short it when you want to receive serial into your running program. Note that all resistors are 22K.
 

Charliem

Senior Member
Sorry for butting here,but I don't think you can have two way comms via the serial cable on a 18X you would have to go to the 28X. I wish the 18X,08m and the 14m could do this.Maybe I misunderstood what you were asking.
 

moxhamj

New Member
Charliem - I'm not sure what you mean as it is quite easy to set up two way comms via the serial cable on any picaxe. You can implement all sorts of RS232 protocols including xon/xoff and full handshaking with RTS and CTS.You just have to remember which plug the cable is connected to. http://www.instructables.com/id/Control-real-world-devices-with-your-PC/ takes you through the steps, including when to unplug the cable from the programming pins and plug it into the communication pins. You can use Hippy's circuit and a jumper/switch where the link is. Or even build a board with two D9 plugs on it.

But maybe I misunderstood your comment about smaller picaxe chips not being able to do something. Looking at it light heartedly, any suggestion by anyone on this forum that a picaxe can't do something is likely to result in a solution being posted forthwith! If only I could get a picaxe to do surgery...
 

Charliem

Senior Member
Hello Dr Acula,

What I meant was using the same pins used to download the program to the picaxe,the 18a,x,08m does not have that capability you can only send via the download cable.At least that is what I read about using serrxd and sertxd
 
Last edited:

phillyk

New Member
Ahh, Ok I see now.
I got into Picaxe because of Dr. Acula's walk through on Instructables, but I didn't read it "all the way" & missed that "switching connections" part.

I will wire up a "communication" circuit on my breadboard tonight and let you all know how it works. Hopefully, Once I program my chip with working code, I won't have to swap back & forth to the programming cable. And I probably should get an extra USB "Download" cable, then I wouldn't have to swap my USB to serial dongle between my "I/O" and the download circuit/cable.

I just hope I have some resistors around. I think I am really close to having a rather crude, but 18x based 2 axis machining center. and I think, pound for pound, that that's something really amazing.
I think I might be able to squezze a 3rd axis into it with a stepper circuit.
 

moxhamj

New Member
Hi Charliem (and phillyk)

There is no need to use the special download cable. All it really does is bring out three wires, and they chose a stereo plug as it happened to have 3 wires and was cheap. But D9 connectors are pretty cheap too. You can wire a D9 extension lead using ribbon cable and IDC plugs and it will take all of 2 minutes. Or just bring out bare wires and use Hippy's circuit. For an 08M for instance, pin 0 sends the data back to the PC, whether that is acknowledge data from programming, or data you might code with a serout 0,etc. The serin goes to either the programming pin or another pin.

Re interfacing with a PC, sooner or later it is worth writing some code in a language like VB or C and getting total control of the data, rather than relying on third party software. Do you need any help with that?

I'm not sure how to explain this as I'm not sure which bit is unclear. Are you ok with the concept that a picaxe can both be programmed with a serial cable, and use the same cable to communicate with a PC (or indeed, with another pciaxe, or any device that uses RS232)?

addit oops phillyk replied at the same time I did...

Yes, get a simple connection working first.
 
Last edited:

phillyk

New Member
I am comfortable using the serial cable, it is the Pins that confounded me.
I tried to wire something today to use
Code:
serout 0,n2400, ("code")
serin 0,n2400,("xy")
But I think I was doing something wrong; didn't have time to make a breadboarded additional serial input circuit. I didn't get any of the output.

Is it OK to use serout with "output zero" and serin with "input zero"? Or does that logistically end up being like "not cool"

And why do things "seem" to work in the simulator, no matter what I do? .. Well it looks for serin data on pin 3 even. I am never quite sure my Serout works while simulating.

Also, Hippy's circuit, is that in place of the hard wired circuit for Downloading that my "power project board" uses? Thats probably my big holdback, I am using the existing board and like it very very much.
I will wire a little side board for serin & serout if necessary & if so, can use 10kresistors right? Thanks for the help every one.

Oh 1 Last thing, as far as whats going to be handling the data to the serial port, I have some VB code that Dr. Acula poste & I might be able to get adapted or my brother has serious image manipulation & VB experience & has found some serial code for it that he feels comfortable using.
 

hippy

Ex-Staff (retired)
Staff member
You can use pin 0 for both SerIn and SerOut, for SerIn it will use Input Pin 0, for SerOut it will use Output Pin 0, entirely different physical legs.

For your serial interface side board, the inline series resistor to the Input Pins should be 22K to interface to a PC's -12V/+12V; use two 10K's in series to get 20K, should be close enough.
 

phillyk

New Member
To go forward, we go backwards.

I wired up a proto board with a 22k resistor between RX & Ground of my picaxe board. Also A 22k resistor between RX and output pin 0
I can now successfully send input & see my picaxe change state.
But I do not seem to get output. I have my output circuit with a wire between the computer TX & my "Output pin 1" of my picaxe.
My code sending from the picaxe is as follows:
Version A:
serout 1,N2400,("Gimme Data x,y",#b4,#b5)
Version B:
serout 1,T2400,("Gimme Data x,y",#b4,#b5)

I think at this point I have a bad connection someplace on the circuit I wired up. And to think, I went through the trouble of using a "stereo" headset jack salvaged from an old CD rom drive. (it makes swapping fairly straight forward.

Tomorrow I will do some continuity test's & let you know if I can resolve it, if something I described glares obviously wrong let me know.
 
Last edited:

moxhamj

New Member
The picaxe programmer sends data but it won't give a successful download unless it gets some data back from the chip. Thus, if you are able to program a picaxe chip then the data must be getting back to the PC. So this points to a software problem. Not sure what exactly - I'll think about it a bit more.
 

phillyk

New Member
This is not through the "download" hard wired circuit. This is through a circuit of my own devising from the schematics provided by here & the documentation. I think it's either a loose connection, or I need to put a resistor between TX & the output pin of the Picaxe & actually, i could be making the mistake of trying to use the "output" after the "power project board" Diode's or whatever extra circuits those are. I think I saw a note on that someplace.... Tomorrow, I will try to post pictures if I don't find anything.

Thank you all, by the way for the help on such seemingly simple things.
 

phillyk

New Member
This morning, i did some tinkering with getting data from my Picaxe over "output 1" and still had no success.

I am wondering who knows the "power project board" if It might be my problem, since I think, it buffer's some of the output's or something.

And if that'd disrupt regular serial communication. IF so, I will adjust my serial circuit & try to attach the lead from my "comm board" directly to the PicAxe.
 
Last edited:

eclectic

Moderator
Philly.

Just to check. “power project board”.

Which one?
Is it the CHI030 (with a ULN2803) or the

CHI035 (with the four power transistors)?

http://www.rev-ed.co.uk/docs/chi030.pdf

Inputs are no problem.

You CAN connect directly to Output 0,
but please make sure that you look at page 7 or 8 FIRST.

e.
 

phillyk

New Member
Yes your right, the CHI035, "High Power Project board" yes..
That is what I am using. Should have checked the schematic. Hrm. there are 2 sets of 3 Solder points on the board, 1 labeeld "X1" between the 2 chip's on my board. I will test & see if 1 of those is in fact a contact point for Pin0 & see if I can use that, (or something for another output pin) and thus bipass those Transistor's. COmplicated little circuit board... Really so much more than I bargained for. Really high level of potential.
 

phillyk

New Member
Not the Crystal!

Well, took the time to read out the end of that spec sheet. Not going to try canabalizing those contacts where X1 crystal could go. Now, I had a problem with inputs 0 & 1 when I first was expirementing with this board, jumping around on me. But if I read right, by adding resistors R6 & R7 I make those digital inputs.

Also, I tested & used my finger to hold the TX wire of my "serial" interface to output1 & can successfully recieve & send data & my program operates very well. On the picaxe side, so far. Tisk tisk, I wish I had more hours in the day.
 

Texy

Senior Member
serin 3,N4800,("xy"),b4,b5

There is no Input Pin 3 on a PICAXE-18X. I guess you are using "3" to be "leg 3", Serial In as used for downloading - unfortunately that won't work with an 18X and you will see resets and all sorts of peculiar failures.

What you need to do is duplicate the 10K/22K download interface but take the 22K to an Input Pin ( leg 1, 15, 16, 17 or 18, Input Pins 2, 6, 7, 0 and 1 respectively ). The output to the download interface ( used by SERTXD ) can also go to thie output for this serial interface.

However, here's an easy alternative way to do it ...

Code:
                                              .-----------------.
                               ___            |                 |
                          .---|___|---------->| Input Pin       |
                          |    22K            |                 |
TX to PC    O<------------|-------------------| Serial Out      |
                          |    ___            |                 |
RX from PC  O---------.---^---|___|---.------>| Serial In       |
                     .|.       22K    |       |                 |
0V          O---.    | |              O       `-----------------'
                |    |_| 22K          O Link
               _|_   _|_             _|_
Open that link when you want to download, short it when you want to receive serial into your running program. Note that all resistors are 22K.
I,d also like to use the download cable to send and receive data to a PC's Comm port and the circuit above is one suggestion. However, I,m currently using the AXE090 board to experiment with and I,d rather not change the existing 10K resistor in the download circuit, and of course I,d need to solder in a wire to the junction of the resistors as well. Is there no other way except wiring in another stereo socket as another serial port?
Of course, I could move up to a picaxe that supports the serrxd command.
Texy
Texy
 

hippy

Ex-Staff (retired)
Staff member
You're going to have to do some modifications unless you do choose something which supports SERRXD. You may get away with leaving the 10K as is, I haven't tried it.
 

moxhamj

New Member
It isn't *that* hard to wire in another stereo socket. Just duplicate the 10k/22k circuit for PC to picaxe input pin, and the output to the PC just goes directly. When changing from "downloading" to "communicating", you will be changing programs, ie shutting down the picaxe programmer, and opening up some other program, eg vb.net or hyperterminal, and so the extra time to change a plug over won't really matter. I wouldn't try to do it with the same plug. You might accidentally send some codes from vb to the picaxe that put it into download mode.
 
Last edited:

ramasule

Member
Hi,

I have a usb to rs232 dongle which i connecto ta rs232 cable. When I tried the "standard 22k 10k network it did not work" upon measuring I found out my el cheapo rs232 only puts out 5 volts. So you may have this problem.
I took out the resistor networks and just put in 180 ohm in series with the tx and rx and it seems to work just fine.

I dont know if this was the correct way to do it and maybe one day when I forget and plug my chip into a true 232 connection it will go pop :).

Derek L
 

hippy

Ex-Staff (retired)
Staff member
Most times the 5V from USB and laptops works with the 10K/22K sometimes not. Reducing the 22K is probably the best way round that but does present risk if a true -/+12V RS232 cable is connected.

A 4V7 zener diode pointy-end to Serial In and to 0V would offer some protection. The hardware experts can probably comment on that better than I can. One option would be a switched 180R in parallel with the 22K. All you have to do then is remember to switch it in or out as required.

The best option is a MAX232 buffer in a pass-thru mode. That will convert almost any signal ( 0V/5V, -/+12V ) into a -/+12V signal which will drive any 10K/22K PICAXE.
 

ramasule

Member
Wouldnt know about the rev-ed cable.

I have china made usb-rs232 adapters with the rs232 download cable from rev-ed for the picaxe experimenter board.

But I like to use a straight rs232 cable as I'm trying to move away from the experimenter board as much as possible.
 

moxhamj

New Member
From China eh? Oh gawd! Wait till Dippy wakes up...

Seriously though, there has been a lot of discussion on this point. Essentially, the brand of USB to RS232 that Rev Ed sell gives the correct voltages. It also gives true RS232 voltages. Any other brand may or may not work. You won't know till you get it and unwrap it and measure the voltages.

If it isn't giving -9 to -12V on pin 3 of the D9 cable when resting then it isn't true RS232. Workarounds will certainly work ok but be careful if you change the resistor values, then change your computer to one that does use proper RS232. As you say, it might go pop. I zapped my first picaxe that way.
 
Last edited:

hippy

Ex-Staff (retired)
Staff member
Essentially, the brand of USB to RS232 that Rev Ed sell gives the correct voltages. It also gives true RS232 voltages.
It's important to be clear on which USB cable we're talking about. The USB to 9-pin is RS232 compliant AFAIK, the USB to 3.5mm is TTL serial (0V/5V).

The main requirement for any USB serial cable to work with the PICAXE is that it must support the 'break' signal. All the Rev-Ed cables do and most others should but not all do.
 
Top