08M and 28X2 PULSIN differences

DTB Radio

Member
This may be covered someplace, but I haven't found it yet.

Ok, I am on the next phase of my life-sized RC boat project. This is my first adventure into RC with PICAXE chips. What I'm going to do is use (temporarily, for tests only!!!) an aircraft radio set I already have to get the basic code worked out, then adjust it for a ground-lega radio to be named later. The problem I'm having is that I'm getting VERY different values for PULSIN on the 08M and the 28X2. Both are running at the same clock speed (default 4mhz). Can anyone shed any light, or do I need to post more detail? Its not a connection issue since both chips are reading every stick position within the upper and lower limits of the stick movements.
 

BeanieBots

Moderator
Posting connection details, your code and results would be a good idea.
NOT using an airband for experimenting with would be an even better idea:mad:
 

DTB Radio

Member
Connections are as follows: receiver powered from same 5.04V as PICAXE, grounds together, servo signal to pin in 3 on 08M and C.4 on 28X2, servo grounds tied to other grounds, servo V+ not connected.

08M code:
Code:
main:
pulsin 3,1,b0
debug
goto main
08M debug results: upper limit = 194, lower limit = 107


28X2 code:
Code:
main:
pulsin c.4,1,b0
debug
goto main
28X2 debug results: upper limit 130, lower limit overflow to 213

C.4 on 28X2 was arbitrary, happened to be closest to 08M circuit. I tried with several other 28X2 inputs, same results.

I understand the concerns about using an aircraft radio for experimentation. I am inside a thick-walled (over 1 foot in places) concrete/masonry structure, partially underground, with extra metallic shielding. The antenna is NOT extended, and my location is in the middle of a large commercial/industrial area with no RC air operations within a 3-mile radius. The nearest sanctioned RC flying field is close to 10 miles away.
 

BCJKiwi

Senior Member
Manual 1 indicates that the X2 parts actually default to 8MHz - could that be the cause of the different values?
 

womai

Senior Member
Why don't you try reading into a word variable (w0) instead of a byte variable (b0)? Who knows, the result may be overflowing in all cases, so the results you think you get are just the LSBs of the true result, and could be all over the place.

And yes, the 28X2 defaults to 8 MHz, not 4 MHz. You should set the frequency explicitly (e.g. setfreq m4).
 

DTB Radio

Member
Manual 1 indicates that the X2 parts actually default to 8MHz - could that be the cause of the different values?
That is certainly possible, but I'd assumed that the PICAXE firmware for the X2 would have taken that into account. I'll have to test that tomorrow when I'm back at the shop.
 

DTB Radio

Member
Why don't you try reading into a word variable (w0) instead of a byte variable (b0)? Who knows, the result may be overflowing in all cases, so the results you think you get are just the LSBs of the true result, and could be all over the place.
Already did that. It is overflowing in the X2 only. Perhaps more accurately, the MSB of a word variable never changes in the 08M, but shifts 1 bit in the X2. I'm going to test BCJKiwi's theory that its the running speed differences causing the differences. Makes sense, assuming that the firmware in the X2 doesn't compensate for the speed difference.
 
Last edited:

womai

Senior Member
Do you happen to know how your pulses really look like, i.e. have you looked at them with an oscilloscope? I have both a 08M and a 28X2 available so I could run some tests with a signal generator as my source, but I need to know more details about your actual signals to be able to reproduce them. Especially pulse duration and high/low voltage levels.

Wolfgang
 

westaust55

Moderator
That is certainly possible, but I'd assumed that the PICAXE firmware for the X2 would have taken that into account. I'll have to test that tomorrow when I'm back at the shop.
From Manual 2, PULSIN command is consistent. for all PICAXE:
at 4MHz clock speed one count equates to 10usec
at 8MHz clock speed one count equates to 5usec
at 16Mhz clock speed one count equates to 2.5usec

so if no changes to default clock speed, then 28X2 will see double the value of the 08M for a pusle of consistent/same duration.
 

Technical

Technical Support
Staff member
yes, this is correct, pulsin and similar pulse commands are always referenced to the clock frequency, not the PICAXE type. So if a chip is running at 8MHz (as the X2 defaults to) the value will be different to a default 4MHz system (08M).
 

DTB Radio

Member
OK, definitely confirmed that it was just the running speed differences. At 4mhz, both chips give the same results. That's what I get for moving too fast through the manual....
 
Top