www.robowars.org

RoboWars Australia Forum Index -> Builders Reports

DumHed's PICaxe stuff
Goto page Previous  1, 2, 3, 4  Next

Post new topic   Reply to topic
  Author    Thread
Spockie-Tech
Site Admin


Joined: 31 May 2004
Posts: 3160
Location: Melbourne, Australia


 Reply with quote  

quote:
Originally posted by DumHed:
quote:
Originally posted by NMO:
I discovered the out by 20 problem

Yeah I remembered that, but this is a similar problem in a completely different place. - I'm reading a serial data stream, and the byte value I receive is different to the one I transmit!

I'll need to set up some extra monitoring at each end and see where the values go funny.




Remember that the PULSIN command produces a dual-byte *word* as its output. Looking at your register usage definitions in the code you posted earlier, the "signal" label is only defined as a byte, with another value in the following byte.

This means the second byte of the signal word could get overwritten elsewhere in the code, causing the signal word to not have the value you expected.

You may have already fixed this since you posted your code, since I think Neweyn mentioned it, but it caught me once.
_________________
Great minds discuss ideas. Average minds discuss events. Small minds discuss people

Post Sun Feb 05, 2006 11:31 am 
 View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
DumHed
Experienced Roboteer


Joined: 29 Jun 2004
Posts: 1219
Location: Sydney


 Reply with quote  

yeah, as mentioned this is a completely separate issue.

It's a serial data stream, nothing to do with the pulsin command or any timing measurements.
The value is a byte, being stored in a byte register, and it receives the previous byte perfectly.

My original PWM controller code used b0 for the pulsin (cos I copied it from Aaron Razz), but the way I was using b1 meant that even if it was trashed by a pulse value of over 255 I re wrote it before I needed to read it.
I changed that to a word register later just to make sure it was being done 100% properly Smile
_________________
The Engine Whisperer - fixer of things

Post Sun Feb 05, 2006 4:52 pm 
 View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
DumHed
Experienced Roboteer


Joined: 29 Jun 2004
Posts: 1219
Location: Sydney


 Reply with quote  

ok this serial problem is really strange!!

Basically I'm sending out a serial data stream from the TX that has an address byte followed by channel data for each of the three channels, then the RX is using the SERIN command with the filter containing the address byte value for the channel it needs to decode.

The idea is that SERIN waits for the address byte, then grabs the next byte and saves that in a variable for the channel data.

TX:

code:
SEROUT 0,N2400,(1,chan1,2,chan2,3,chan3)



chan1, chan2, chan3 are obviously the channel data values, and the 1, 2, 3 are address values.

RX:
code:
SERIN data_in,N2400,(addr),stream



data_in is the input pin, addr is the address value, stream is the channel data.

Now, one would assume that this is a pretty simple thing (apart from being trapped in the SERIN routine if there's no valid data), but my input data is offset by about 20 (I think it's actually 17) on channel one.
If I change the address to channel 2 I end up with the data being offset by ~5 instead of ~20!

I've tried making the address bytes values of 11, 12, and 13 instead, slowed it down to 1200 baud, split up the transmit routine and paused between each byte, tried inverted logic, and pretty much anything I can think of, but it gives the exact same effect!

This afternoon I replaced the RF modules with a bit of wire, but it still seems to have the data offset by a "few".

So, I think maybe the serial input routines used in the PICaxe are a bit buggy, or there are some strange timing issues.
I'll see if I can get it on a good scope at work tomorrow and manually see what the data looks like at each end.

Chances are the PICaxe serial handling and clock accuracy are just not good enough, coupled with the slight timing fluctuations induced by the RF link.
The really weird thing though is that the address bytes are always received perfectly, and I don't get any anomalies in the data, just a constant offset from the correct value.
Thinking about the way serial bytes are sent, for an offset of 17 I must be dropping the first and fifth bits out of the byte!
This seems like a strange thing to be happening, but maybe it's possible.

Another weird thing is that the received values are still within my exact range (100-200). So even when it's offset by 17 (mid point of 133 instead of 150) I get a minimum of 100, and a maximum of 183.

A value of 100 means it's getting bits 7, 6, and 3
183 needs bits 8, 6, 5, 3, 2, 1

It doesn't make any sense!

I think I'll go pack to transmitting a pulse width Razz
_________________
The Engine Whisperer - fixer of things

Post Mon Feb 06, 2006 10:09 pm 
 View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
Glen
Experienced Roboteer


Joined: 16 Jun 2004
Posts: 9481
Location: Where you least expect


 Reply with quote  

did you try swearing at it? Very Happy
_________________
www.demon50s.com - Minimoto parts
http://www.youtube.com/user/HyzerGlen - Videoooozzz

Post Mon Feb 06, 2006 10:11 pm 
 View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
DumHed
Experienced Roboteer


Joined: 29 Jun 2004
Posts: 1219
Location: Sydney


 Reply with quote  

not yet!!
you might be on to something there Razz

I'm really getting the feeling that the RF modules and the PICaxe's rather basic serial handling is the problem.

I'll give it a go using a pulse train type setup like conventional R/C gear uses and see how that goes.
At least that way it can't get stuck waiting for data, and it'll work with pretty much any type of radio / IR link (spark gap transmitter!)
_________________
The Engine Whisperer - fixer of things

Post Mon Feb 06, 2006 10:17 pm 
 View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
Spockie-Tech
Site Admin


Joined: 31 May 2004
Posts: 3160
Location: Melbourne, Australia


 Reply with quote  

might be worth asking over at the picaxe forums - http://www.rev-ed.co.uk/picaxe/forum/

I doubt the serial input routines would be that buggy, they've been used in some prety complex projects that I've seen and havent heard mention of that type of problem, you never know though..

How about just writing a from-scratch very simple serial echo routine into it to test the serin & serout commands. Sometimes if I get stuck on a weird bug, I'll do that sort of thing to eliminate all the other possible causes from other areas of the code.

Dont use any bits of code from your earlier program, or you might take some obscure bug with it. Helps you figure out things on occasion.

Let us know when (if ?) you find it.
_________________
Great minds discuss ideas. Average minds discuss events. Small minds discuss people

Post Tue Feb 07, 2006 12:51 am 
 View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
NMO
Experienced Roboteer


Joined: 16 Jun 2004
Posts: 486
Location: Melbourne


 Reply with quote  

If your inteneding on using the servo command to drive a speed comtroller in your receiver I may have found a solution to serin getting stuck. It appears as though there is only 1 timer built into the picaxe as I have noticed that while the serin command is running the servo command stops. hence if the serin commandf gets stuck i9n it's endless loop it'll failsafe the IBC.

Post Tue Feb 07, 2006 6:55 am 
 View user's profile Send private message
DumHed
Experienced Roboteer


Joined: 29 Jun 2004
Posts: 1219
Location: Sydney


 Reply with quote  

hehehe, well that's kind of funny really - kind of solves its own problem if you're driving servo outputs Smile

Brett: all this is being looked at in a simple serial echo routine. I haven't had this version driving any sort of outputs or doing any other processing yet.

I had the serial link controller working before, but it had the values offset by 27, and I was just adding 27 to fix it.
With this version I can't just add to it because it's still staying within my channel value limits, so I'd never be able to get full reverse.

In the end, I think there are timing issues that will prevent this from being a reliable solution, so for now I will go to the pulse train system.
The idea of this is to make something that's reliable, and based on cheap and easy stuff to get.
I'm sure it'd work well using more expensive serial RF modules, PICs running on proper crystal oscillators and using hardware UARTs, but I like the idea of making it work with the simple stuff Smile
_________________
The Engine Whisperer - fixer of things

Post Tue Feb 07, 2006 7:48 am 
 View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
Ajax
Experienced Roboteer


Joined: 17 Jun 2004
Posts: 298
Location: Sydney


 Reply with quote  

One thing that could cause droping of bits is if the Picaxe internal resinator is not running at the correct frequency 4MHz. I haven't played with serial commands much so I don't know if it would work or not.

you could try using the following command to correct it.

calibfreq

Syntax:
CALIBFREQ {-} factor

- factor is a constant/variable containing the value -31 to 31

Function:

Calibrate the microcontrollers internal resonator. 0 is the default factory setting.
Information:

Some PICAXE chips have an internal resonator that can be set to 4 or 8Mhz
operation via the setfreq command.

On these chips it is also possible to ‘calibrate’ this frequency. This is an advanced
feature not normally required by most users, as all chips are factory calibrated to the most accurate setting. Generally the only use for calibfreq is to slightly adjust the frequency for serial transactions with third party devices. A larger positive value increases speed, a larger negative value decreases speed. Try the values -4 to + 4 first, before going to a higher or lower value.

Use this command with extreme care. It can alter the frequency of the PICAXE
chip beyond the serial download tolerance - in this case you will need to perform
a ‘hard-reset’ in order to carry out a new download.

The calibfreq is actually a pseudo command that performs a ‘poke’ command on
the microcontrollers OSCTUNE register (address $90).

When the value is 0 to 31 the equivalent BASIC code is

poke $90, factor
pause 2

When the factor is -31 to -1 the equivalent BASIC code is

let b12 = 64 - factor
poke $90, factor
pause 2

Note that in this case variable b12 is used, and hence corrupted, by the
command. This is necessary to poke the OSCTUNE register with the correct value.
_________________
It's all about the destruction.

Post Tue Feb 07, 2006 8:13 am 
 View user's profile Send private message Send e-mail MSN Messenger ICQ Number
NMO
Experienced Roboteer


Joined: 16 Jun 2004
Posts: 486
Location: Melbourne


 Reply with quote  

It would be good if we can get reliable serial data going, as then it may be possible for 2 people to operate on the same frequency. IE your using qualifiers 1 2 3 If I used qualifiers A B C or something else then in teory your receiver wouldn't respond to my transmission. Don't worry though I'm not trying to invade your use of 433.92 Mhz

Post Tue Feb 07, 2006 8:17 am 
 View user's profile Send private message
DumHed
Experienced Roboteer


Joined: 29 Jun 2004
Posts: 1219
Location: Sydney


 Reply with quote  

since both would be transmitting at the same time I think the result would be no one being able to receive anything cos the data will be corrupted.

I think serial data can be done, bit the PICaxe is maybe not the chip for it.

Ajax: I'm sure some tweaking of the clock would help, but in the end I need these things to have a fair bit of "give" to work reliably, and they'll be exposed to all kinds of temperature changes, electrical noise, and multiple chips will be used.
I could do some sort of auto calibrate program (serial echo and tweak the clock up and down till it gets the right values) but I think it's still going to be too touchy.

In other news, my pulse train style system is working pretty nicely, so now I just need to get it doing PWM (basically mean un commenting a bunch of stuff) and do some range testing Smile

Interestingly, when using the RF link all pulses end up about 50us longer than they do when using a short cable.
That's probably part of the serial issue, but it's a lot easier to correct in this setup.

Also, feel free to also use 433MHz.
I'll be looking into other frequencies once I have it working.
I'm thinking of modifying a 2.4GHz video transmitter / receiver set to see if I can send pulses or data over that.
They tend to have selectable channels too.
_________________
The Engine Whisperer - fixer of things

Post Tue Feb 07, 2006 9:05 am 
 View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
Valen
Experienced Roboteer


Joined: 07 Jul 2004
Posts: 4436
Location: Sydney


 Reply with quote  

If you want to i have some 16F628A's running in serial mode you could try
_________________
Mechanical engineers build weapons, civil engineers build targets

Post Tue Feb 07, 2006 9:13 am 
 View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Knightrous
Site Admin


Joined: 15 Jun 2004
Posts: 8511
Location: NSW


 Reply with quote  


quote:
I'm thinking of modifying a 2.4GHz video transmitter / receiver set to see if I can send pulses or data over that.


Jaycar sells some 2.4GHz RX / TX modules. Really small suckers with a few channels on them too. mainly used for AV, but it might be possible to use them for bot control.

Jaycar catalog numbers:

TX: QC-3590
RX: QC-3592
_________________
https://www.halfdonethings.com/

Post Tue Feb 07, 2006 10:26 am 
 View user's profile Send private message
DumHed
Experienced Roboteer


Joined: 29 Jun 2004
Posts: 1219
Location: Sydney


 Reply with quote  

yep, those are the ones I'm thinking of, but I also have a pair of similar ones at home I might hack up.

I have a feeling they need a composite video sync to do anything much, but it might be possible to connect further down the signal stream.

They also transmit two audio channels over the same connection.

Anyway, the pulse train sending system is working nicely now, and the hardware watchdog system also seems to be the go.
With the transmitter turned off I get a false good signal about every 15-30 seconds, which won't be enough to enable the hardware watchdog, so it should all work nicely Smile
_________________
The Engine Whisperer - fixer of things

Post Tue Feb 07, 2006 11:30 am 
 View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
DumHed
Experienced Roboteer


Joined: 29 Jun 2004
Posts: 1219
Location: Sydney


 Reply with quote  

I got basically all my software working, so today I made up PCBs for a bunch of stuff.

Transmitter board:
This fits inside a cheap 2 channel radio, using the original board mounts, control sticks, switches, and battery holder.
One of the old channel reverse switches is now used to enable mixing to drive tank control.
There are connections for two different types of RF module (the cheap Jaycar one, and a super high quality FM 433MHz module I had at work)

Receiver board:
There's one of these needed per channel, and they connect together to take the same pulse stream from the RF module.
I've designed this so the same board can be used for my radio system, or for traditional servo inputs, with a quick software reload.
I have some ideas for these that will allow them to do mixing, or have gyro inputs (from a $10 gyro module) so a complete controller for two motor channels will require two of these boards and two of the power control boards.

RF module board:
I made up a small PCB to hold one of the FM RF modules I'm using, to make it easier to connect to.
The Jaycar modules connect directly to the receiver boards very easily.

PWM and relay reverse board:
This is an opto isolated board containing 4 MOSFETS, 3 for PWM control of the motor, and 1 to switch a couple of horn relays for reversing.
I could probably go for a smaller transistor for the relay control, but this way means less different parts are used, and it'll handle any size relay(s).
I'll also make a full MOSFET H-bridge board with the same interface once I have a better look at the driver chip options.

Mixer:
I made a mixer program for the PICaxe so I figured a super tiny mixer module could be handy for some people.
It's about as small as possible, with two inputs, two outputs, the PICaxe, and a bypass capacitor.
I haven't tested this yet, but there's no reason why it won't work Smile


So, tomorrow I'll make up the rest of the boards and test them out.
I'm looking forward to having a completely custom control system in my robots!

I have a few more ideas to try out too, with some gyro / accelerometer stuff, and I want to do a fully mixed two channel relay controller using one PICaxe, to work from my transmitter - for possible use in other bots like Woktronix.
_________________
The Engine Whisperer - fixer of things

Post Wed Feb 08, 2006 11:11 pm 
 View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
  Display posts from previous:      

Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 3 of 4

Goto page Previous  1, 2, 3, 4  Next

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Last Thread | Next Thread  >
Powered by phpBB: © 2001 phpBB Group
millenniumFalcon Template By Vereor.