Odd baudrates

Rasmus

New Member
I'm wondering if its possible to trick the 28x1 into accepting serial baudrates
of non standard values.

I need a baudrate of 10400 to communicate with a system on several pins.

Raz.
 

Rasmus

New Member
But, is it possible to do this on an ordinary In-port?

I need 3 serial in's at 10400 baud to communicate with a OBD-II system in my car.

Raz
 

hippy

Ex-Staff (retired)
Using the on-chip hardware ( HSERSETUP or by poking SFR's ) it is possible to select non-standard baud rates for the Serial TX and RX lines.

For SERIN and SEROUT which use bit-banged software drivers it is not possible to use other than the standard 600, 1200, 2400, 4800 baud rates and multiples of those when over-clocked. You might be able to find an external crystal frequency value which will translate one of those baud rates at 4MHz to 10400 baud.

To handle three serial inputs, I would recommend using the on-chip high speed serial interface and multiplexors to select between them.
 
Last edited:

tiscando

Senior Member
To try and get normal serin at 10400, then you need to use:
Setfreq m8
Experiment with calibfreq using positive values (up to 15)
serin pin, n/t9600 (closest to 10400), (data).

For example,
Code:
setfreq m8
calibfreq 15
...
serin 2, n9600, (data)
Although I'm not sure if it would work.

Only use the calibfreq command if you can easily hard-reset your picaxe, e.g. there is a picaxe reset button. Take a look at the manual on the calibfreq command for more info.

This procedure doesn't work with the 08, 18, M, and A parts, because they dont support n9600_8 baud. It is also not applicable with the 28X and 40X parts because they require an external resonator.

EDIT: hippy posted at the same time. Is it really possible to get 10400 using calibfreq?
 
Last edited:

hippy

Ex-Staff (retired)
Is it really possible to get 10400 using calibfreq?

Possibly, and good suggestion with CALIBFREQ, something I'd not considered.

While testing CLIBFREQ under other circumstances I know it is possible to move baud rates beyond normal tolerances ( around +/-6% ) on some chips and 10400 isn't too far from 9600. That may work, so testing the theory seems to be the next step to try.
 

eclectic

Moderator
Re the Calibfreq approach.

I don't know the relationship between
Pwmout frequency and Serial,
but I've just tried the following

Code:
#picaxe 28X1
main:

pwmout 1 , 103, 208 ; 9600 from wizard
pause 5000

calibfreq 11
pause 5000

calibfreq 0
do
loop
Measured frequency values, using a cheap 'scope.
9630
10.43 kHz
9630

Obviously, results will vary.
e
 
Last edited:

hippy

Ex-Staff (retired)
Thanks eclectic.

Relationship should be proportional, as frequency changes by X% so too will PWMOUT and everything else. With the headroom ( CALIBFREQ can go up to 15 ) there will hopefully be a sweet spot where it works but will depend on particular chip.
 

eclectic

Moderator
I've just used two separate 28X1 boards.
Joined by Gnd and serout connector.

Code:
#picaxe 28X1
;tx
pwmout 1,103,208
calibfreq 11

main:

for b0 = 0 to 255
serout 0,n9600_8, (b0)
pause 250
next

goto main

On the receiver board, there are eight LEDs on outputs 0-7
Code:
#picaxe 28x1
;rx

pwmout 1 , 103, 208
calibfreq 11
main:

for b0 = 0 to 255
serin 0, n9600_8,b1

sertxd (#b1," ")

outpins = b1
next

goto main
The PWMout frequencies both show as 10.43 kHz
The terminal screen shows gobbledegook, (as expected).
The LEDs light in a Binary countup sequence.

e
 

womai

Senior Member
Another option could be to use a multiplexer or analog mux to route the 28X1's hardware serial pins to the particular device you want to communicate with at a given time.
 

hippy

Ex-Staff (retired)
@ eclectic : Again, thanks and good experimentation. If you wanted to verify the data received you could issue a "SETFREQ M4/M8" before the SERTXD, another SETFREQ and CALIBFREQ after to be ready for the next non-standard baud rate reception.

The only thought with the above code is whether the baud rate (9600_8) is actually ~10400 or something else ? The theory seems to be sound though.
 

eclectic

Moderator
Edited quote

The only thought with the above code is whether the baud rate (9600_8) is actually ~10400 or something else ? The theory seems to be sound though.
I've tried this program, with my cheapo-scope.

Code:
#picaxe 28X1
main:

serout 1, n9600_8, ("@")
calibfreq 11

serout 7, n9600_8, ("@")
calibfreq 0

goto main
Rough 'scope values
between start high and finish low = ~
1.875 ms cal 0
1.750 ms cal 11

ratio 10400 / 9600 = 1.0833
ratio 1.875 / 1750 = 1.071

Is there a kind person out there,
who owns, say, a Tectronics or two,
who could do some proper measurements?
:)
 

retepsnikrep

Senior Member
Last edited:
Top