Picaxe 18 project board Serial Comms

djh82uk

Member
Hi Guys

it's been a while since ive used a picaxe, I am trying to send a serial transmission from a Parallax Propeller chip, to the picaxe 18 chip in my project board.

It is being transmitted inverted, I have a common ground between the 2 boards, and the Tx lin at the propeller end is pulled low by a 4.7k resistor.

Basically it does not work, the code works great in the sim, i have the Tx lead from the prop, going to port 0 on the input side of the board.

Now some of the documentation says you need to pull the line low with a 10k resistor, as well as an in-line 22k resistor, which for some reason causes the board to start pulling 0.98 Amps from the PSu, (normally 0.01A).

If I just use the 4.7K pull-down it does not use as much ampage, but still it does not work (variable in debug does not change)

I was wondering if anyone can help?

here is my code:

main:
w1 = 0
'for b0 = 0 to 3 ‘ start a loop
serin 0,N2400,w1 ‘ receive serial value
'write b0,b1 ‘ write value into b1
'next b0 ‘ next loop
debug w1
If w1 = 001 then goto led
goto main

led:
high 5
pause 3000
goto main

DJH
 

djh82uk

Member
Hiya

Well I have a completley standard 18 Project Board.

I have a lead going from VSS on the propeller board to the ground pin of input 0 (outer pin)

I have a TX lead pulled down on the propeller side by a 4.7k resistor, the other end goes to input 0 on the 18 project board and thats about it.


/--Input 0---------------Pin 0 ---\
Picaxe -- 4.7K¦ ------propeller
\--Gnd------------------Gnd-----/


One thing I should say, I can get my arduino to receive the serial data with this same configuration, so I know the prop side is ok in that sense

DJH
 

djh82uk

Member
Hiya

I only get that high current draw, when the Gnd is connected between the 2 boards AND the serial cable is plugged into the PC.

Both boards are using seperate power supplies, and im using 2 pc's to do the programming.

I have tried it using input 7 on the project board in case using Pin 1 was conflicting with the download circuit, however it still happens, even with just the 1 gnd cable attatched.

I can't figure out how that can even happen? As the gnd going to picaxe, is in no way connected to the download cable
 

djh82uk

Member
ok, been playing with the multimeter

the input 7 that i am using for the serial RX, is +4.5V and when I transmit from the prop it goes upto +5.4V for a second.

Should it be High?

DJH
 

inglewoodpete

Senior Member
I don't fully understand the circuit here. A diagram would help.

I'm assuming that both chip's power supplies are around 4.5 to 5.0v. Does the prop use a serial conditioning chip like a MAX232?

I'm not sure where the PC fits into the circuit but a desktop PC can output from -12v to +12v on its serial Tx pin.

When you say "the input 7 that i am using for the serial RX, is +4.5V " you are talking about physical leg 16 on the PICAXE 18, aren't you?
 

Dippy

Moderator
I agree with Pete; post a proper circuit diagram INLCUDING the power supplies c/w size/type.

Upload a neat accurate schematic, even if its pencil/paper/scanned.

When 2 power supplies are used AND the ground connection causes large currents to flow then it sounds like a power supply isolation problem unless, of course, you have connected something else wrong.

Does this large current flow when both power supplies and grounds connected but the PCs are disconnected?

Are we talking pukka quality bench power supplies or a couple of 50pence plug-ins?

Have you tried batteries at each end or using a single power supply?

I have had similar incidents with one of my older Tektronix which doesn't isolate ground lead from mains PSU.
 

hippy

Ex-Staff (retired)
I've had this configuration working, both transmitting from the Propeller to PICAXE and receiving from it. It is not absolutely necessary to use any R's if both are running from the same 3V3 supply but 1K is strongly recommended and must be used if the PICAXE is running from 5V. If you've put 5V into a Propeller without an R you may have damaged it or that pin.

The R from PICAXE Tx to Propeller Rx can in practice go much higher than 1K. You don't need any pull-ups or pull-downs providing you are not planning to separate the two parts while expecting either to keep working and not receive random data.

That near 1A current draw sounds like something is seriously amiss with the circuit configuration or wiring. Depending on what caused that current draw, you may have damaged some components, Propeller or PICAXE. Fingers crossed that that hasn't happened.

Finally, when getting this working ... use Nxxxx baud rates on the PICAXE and adjust the Propeller code to suit that. This avoids a number of complications you may otherwise run in to. With this Nxxxx configuration, serial is idle low (0V), active high (+V).
 

djh82uk

Member
Hi Guys

I will try and get a schematic done when I get 5 mins, The propeller is still working ok when talking to an arduino, so im ok there, I also have another picaxe chip i can try (18X).

As I said I only get the high ampage when the download cable is plugged in, but something must definatley be wrong. I use a 12V PSU to supply the Prop project board.

But I guess I could use the VDD and VSS from the Prop board to power the Picaxe board to see if that gets rid of the problem, i just want to make sure that the VDD and VSS come from the regulator as I suspect it does.

Im only playing with one way comms atm, so I will try a 1K resistor inline.

I Have the TX from the prop tied low with a 4.7K resistor which should make in run at N2400 as thats how it is configured.


I do hope I can get this working.

Thanks

DJH
 

moxhamj

New Member
0.9A may well have zapped something so you might spend 2 hours trying to get a chip working when that chip is sans magic smoke.

A complete schematic would help a lot as there appears to be a mix here of TTL and RS232. Mixing these will almost certainly zap things.

RS232 uses positive and negative voltages. Resting is minus 3 to minus 12V. On a PC for instance, ground is pin 5 and pin 3 is the output and if you get a multimeter out you will measure something like -11.5V.

The picaxe uses a fudge to program the chip with the 10k and 22k resistors, but it is a special case circuit and can zap other chips that can't handle negative voltages.

Asume RS232 is minus 12V resting and plus 12V when a byte goes through. If you put that into a max232 chip (I buy them in batches of 10), you get an inverted TTL signal. This is resting at 5V and when a byte goes through it is 0V. The picaxe calls this "True" polarity. I'm not sure what a propeller calls it.

Or course, you can send data with TTL levels too, but you need to get the polarity right, true or inverted. But if you do connect a picaxe to a propeller with a serial link, you still need some level translation because a picaxe uses 5V and a prop uses 3.3V. Unless you power the picaxe from 3.3V. But if you ever do this link, you can't ever plug any of that into a PC serial port because you are almost certain to zap things.

So, even though it seems a bit silly to go picaxe<=>max232<=>wire<=>max232<=>propeller, there is the big advantage that you can't zap things. RS232 is very robust, as are max232 chips as you can plug things the wrong way round, or plug powered boards into unpowered boards, and you won't get mysterious 900mA current drain going into some poor unsuspecting chip.

RS232 takes a bit of getting used to. Sing out if you want some circuits. You might need some max232s and 4 1uF capacitors for each chip. But you can simplify it greatly by using just 3 wires of the D9 plug. Rx, Tx and Gnd. On a male D9 plug, data comes out of pin 3, goes into pin 2, and ground is pin 5. On a female D9, data comes out of pin 2, into pin 3 and ground is pin 5. So if you use that standard, and put D9 plugs on every board you build, it will be zap proof.
 

djh82uk

Member
Hiya

I see how the voltage differences could be a problem, I am also playing with using SX48 chips, as while they also run on 5v, you can set the pins to TTL or CMOS. I guess if i run at TTL levels I can make it work, Although I did want the picaxe, so i could test the whole project idea without spending ages writing code thats much more complicated for the SX as it takes me a while to get my head around certain things.

Its a shame i only have 1 max232 chip here as I would give it a go tonight, but I may order some as they can always come in handy.

I think i need to sit down and go through this properly, i spent ages doing the propeller side of it, and now am in a rush to see the project reach fruition.

One question I have, does it have to be serial, or could you use SPi, or is that only for talking to other components like eeproms etc?

It's a shame wireless tranceivers are so expensive as that would have made everything a lot nicer.

Thanks

DJH
 

moxhamj

New Member
SPI and serial are kind of the same thing. Just serial data going down a wire. SPI uses a clock line as well as a data line, so there are some extra lines. That means SPI can run at any data rate. Serial needs fixed data rates, eg 1200 baud or 2400 baud (or faster). Then there is the RS232 part, which defines the voltage levels. RS232 is about making the signal more "robust" so it can go further, so you can short out lines, so you can feed outputs into outputs etc. SPI signals could be 'robustified' by putting them through a max232 if you wanted to, but it would be a bit non standard, and not really necessary for comms over a few metres.

But - if you leave the PC out of the loop for the moment, I wonder about a very simple solution. Run the picaxe off the propeller 3.3V supply.

The picaxe can go down to 3V (probably lower). So now you don't need level translation. And it will either be true or inverted polarity coming out of the propeller and you can test that by setting up the serial comms code, output a byte from the prop and see what volts you have afterwards. If 3.3V then use true polarity on the picaxe.

If that works, there actually are ways of getting a picaxe to talk to a PC (using another 22k/10k pair on another input pin, and use the same output pin as for programming, then use a SPDT switch or jumpers to switch between programming and talking) so there is no reason you could not have a PC/Prop/picaxe all talking to each other.
 
Top