www.robowars.org

RoboWars Australia Forum Index -> Builders Reports

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

Post new topic   Reply to topic
  Author    Thread
DumHed
Experienced Roboteer


Joined: 29 Jun 2004
Posts: 1219
Location: Sydney


 Reply with quote  
DumHed's PICaxe stuff

OK, I thought I'd jump on the PICaxe bandwagon since I wouldn't mind some custom control stuff for future bots Smile

My first program is a PWM speed controller driven from a normal RC servo channel which I'll probably use in the boat, and maybe in the ram bot.

It provides a PWM output and a reverse pin, and seems to work pretty well.
It has a basic noise gate sort of setup to reduce interference problems, but with my ultra dodgy receiver in a very noisy environment it gets the occasional glitch through. edit: with the pause between the two pulsin commands it seems to not get the glitches. Further testing will really tell Smile
I'll think more about that, but in general it failsafes in that if the transmitter is turned off or the signal goes out of bounds the motor output is turned off.

One of my aims with this was to make configuration easy, so there are no variables hidden in the code. Everything can be adjusted in the setup section and it should all work.
The values in there now are what works best with my radio gear in the small amount of testing I've done.

Anywho, here's the code:

code:

;-------------------------------------------------------------;
;DumHed
;PicAxe 08M PWM Speed Controller
;Updated: 02-02-2006
;(c) Andrew Handmer 2006
;-------------------------------------------------------------;

; RC input setup

symbol neutral = 155    ; pulse length at mid point (ms/100)
symbol range = 45    ; range above and below neutral (ms/100)
symbol dead_zone = 5    ; dead zone (+- ms/100)
symbol full_on = 85    ; Full on output band (%)

; PWM rate

symbol period = 249    ; 249 = 4Khz


; PicAxe Pin Definitions

symbol receiver = 3    ; Servo signal from Receiver
symbol motor = 2       ; PWM Output to Motor
symbol dir = 1       ; direction output pin


; PicAxe Register Definitions

symbol signal = b0
symbol duty = b1
symbol dead_high = b2
symbol dead_low = b3
symbol fail_high = b4
symbol fail_low = b5
symbol sigcomp = b6
symbol PWMduty = w6

;-------------------------------------------------------------;

OUTPUT 1                  ; set IO pins
OUTPUT 2
INPUT 3
LET dead_high = neutral + dead_zone      ; sets dead zone points
LET dead_low = neutral - dead_zone
LET fail_high = neutral + range      ; sets fail safe out of bounds points
LET fail_low = neutral - range

main:
PULSIN receiver,1,signal                  ; receiver pulse input
pause 20
PULSIN receiver,1,sigcomp                  ; pulse comparison input
LET sigcomp = sigcomp - signal
IF sigcomp > 10 AND sigcomp < 245 THEN GOTO main      ; noise gate
IF signal > fail_high OR signal < fail_low THEN motor_off   ; turns motor off if outside signal range
IF signal > dead_low AND signal < dead_high THEN motor_off   ; turns motor off inside dead zone
IF signal >= dead_high AND signal < fail_high THEN fwd   ; drives motor forwards
IF signal <= dead_low AND signal > fail_low THEN rev      ; drives motor backwards

motor_out:
IF duty > full_on THEN duty100   ; set duty to 100% if over full_on value

doit:
LET PWMduty = duty * period / 25   ; calculates PWMduty depending on duty cycle % and period
PWMOUT motor, period, PWMduty
GOTO main

fwd:
LOW dir               ; turn off reverse pin
LET duty = signal - neutral      ; gets pulse width above neutral
LET duty = duty * 100 / range      ; converts pulse to duty cycle percentage
GOTO motor_out

rev:
HIGH dir               ; turn on reverse pin
LET duty = neutral - signal      ; gets pulse width below neutral
LET duty = duty * 100 / range      ; converts pulse to duty cycle percentage
GOTO motor_out

duty100:
LET duty = 100            ; sets duty cycle to 100%
GOTO doit

motor_off:
LET duty = 0            ; sets motor PWM to zero for shutdown
GOTO doit





bah it's a bit hard to read with the word wrapping of comments..
If anyone wants it I'll email Smile
_________________
The Engine Whisperer - fixer of things

Post Thu Feb 02, 2006 10:31 am 
 View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
dyrodium
Experienced Roboteer


Joined: 24 Aug 2004
Posts: 6476
Location: Sydney


 Reply with quote  

Usable on boats eh... i'd buy one! Very Happy
_________________
( •_•)

( •_•)>⌐■-■

(⌐■_■)

YEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH

Post Thu Feb 02, 2006 12:48 pm 
 View user's profile Send private message Visit poster's website MSN Messenger
DumHed
Experienced Roboteer


Joined: 29 Jun 2004
Posts: 1219
Location: Sydney


 Reply with quote  

I now have my PCM transmitter working, using a gutted AM transmitter, a PICaxe, and an RF transceiver board.

I don't have the receiver part working yet, but hopefully tomorrow I will.

At the moment it reads three analog inputs (the two sticks, and another channel for the weapon), and converts them into a serial data stream for the RF module.

I picked up a couple of other RF modules to play around with as well, which should simplify the serial requirements.
_________________
The Engine Whisperer - fixer of things

Post Thu Feb 02, 2006 6:54 pm 
 View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
Knightrous
Site Admin


Joined: 15 Jun 2004
Posts: 8511
Location: NSW


 Reply with quote  

Q: Do those 433mhz modules have crystals/frequency adjusters? Or are they all on the same tuned frequency Shocked
_________________
https://www.halfdonethings.com/

Post Thu Feb 02, 2006 6:56 pm 
 View user's profile Send private message
DumHed
Experienced Roboteer


Joined: 29 Jun 2004
Posts: 1219
Location: Sydney


 Reply with quote  

that depends on which ones you use.

The ones I just picked up from jaycar are very basic, and are fixed in frequency - so no one else better use them Razz

It should be possible to run some sort of multi channel or automatic module in future.
_________________
The Engine Whisperer - fixer of things

Post Thu Feb 02, 2006 6:59 pm 
 View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
NMO
Experienced Roboteer


Joined: 16 Jun 2004
Posts: 486
Location: Melbourne


 Reply with quote  

PULSIN receiver,1,signal ; receiver pulse input
pause 20
PULSIN receiver,1,sigcomp ; pulse comparison input
LET sigcomp = sigcomp - signal
IF sigcomp > 10 AND sigcomp < 245 THEN GOTO main ; noise gate

I like this and might stell it if that's all right. It's and interesting Idea I hadn't thought of. To reduce interference I have been meaning to try adding a diode on the signal line between the receiver and the micro so that the voltage must be above 0.6Volts, however I don't know if that would help. I had a thought that perhaps the micro sometimes is accepting less than a CMOS logic high as a 1.

Anyways good work!!!

Post Thu Feb 02, 2006 8:06 pm 
 View user's profile Send private message
NMO
Experienced Roboteer


Joined: 16 Jun 2004
Posts: 486
Location: Melbourne


 Reply with quote  

a quick note for you.

YOur using b0 and b1 variables. However when you use the pulsin command it stores the variable as a word. ie 16bit number which takes 2 variable us, so if you use b0 it will also place a value in b1. in our applications it would fill b1 with 0

Post Thu Feb 02, 2006 8:10 pm 
 View user's profile Send private message
DumHed
Experienced Roboteer


Joined: 29 Jun 2004
Posts: 1219
Location: Sydney


 Reply with quote  

ahh that's interesting!

I did not know that Smile
I'll have to check it out and see what's happening.

edit: ahh, it won't actually cause a problem because I'm only using b1 for the duty cycle calculations after I'm finished with the pulsin value.
I'll change that tomorrow anyway for proper neatness.

Does it always use a word, or is that only if the value is over 255?

Feel free to use the noise gate idea. It seems to work pretty well.
Without it I'd just get crazy random outputs if I turned off the transmitter.

With the noise gate (and the delay) I haven't been able to get it to play up.

The noise I'm talking about is radio noise, not signal noise into the board though. I was getting full strength pulses out of the receiver when it was picking up interference.
Electrical noise should be fixable with some careful use of bypass caps and a weak pulldown resistor on the input.
If you wanted to be thorough, maybe try a schmidt trigger input buffer or an optocoupler.
_________________
The Engine Whisperer - fixer of things

Post Thu Feb 02, 2006 11:08 pm 
 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  

Beware driving optos from recievers, they can be quite pissweak in terms of drive current.

your noisegate dosent seem to have any "lucky signal" rejection
IE static that looks good will cause PWM.
perhaps some kind of counter?

if good signal then counter = counter + 1 else counter = counter - 1
if counter > 3 then enable outputs
_________________
Mechanical engineers build weapons, civil engineers build targets

Post Fri Feb 03, 2006 12:00 am 
 View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
DumHed
Experienced Roboteer


Joined: 29 Jun 2004
Posts: 1219
Location: Sydney


 Reply with quote  

yeah I might add that and try it out
so far I haven't had a problem with it.

The issue I have is that no matter how much protection you put in, there'll be some time when things manage to get through!
Since static is very nice and random it doesn't tend to cause consecutive pulses similar enough to get through my noise gate.
I will be doing a lot of testing though Smile

One thing I want to avoid too is ending up with no drive at all in a bad signal area. I'd rather have slightly erratic drive than getting stuck in failsafe Smile
_________________
The Engine Whisperer - fixer of things

Post Fri Feb 03, 2006 12:15 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  

hence the 3 outta 10 for signal ;->

cos if you got a bad signal you use the last good signal
It'll stop the output going on, off on off, at something like 50Hz which wont do anything any good ;->
_________________
Mechanical engineers build weapons, civil engineers build targets

Post Fri Feb 03, 2006 12:17 am 
 View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
DumHed
Experienced Roboteer


Joined: 29 Jun 2004
Posts: 1219
Location: Sydney


 Reply with quote  

yeah I might have a play around with that tomorrow
_________________
The Engine Whisperer - fixer of things

Post Fri Feb 03, 2006 12:20 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  

w00t!

PCM is working, using the little Jaycar 433MHz modules.

The other modules I have are better in some ways, but their comms speed requirements make them hard to use with the 08M chip.
_________________
The Engine Whisperer - fixer of things

Post Fri Feb 03, 2006 10:18 am 
 View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
dyrodium
Experienced Roboteer


Joined: 24 Aug 2004
Posts: 6476
Location: Sydney


 Reply with quote  

Damn your a machine andrew! all this in 2 days!? Laughing
Damn school i'd be doing the same if it wern't for it... Crying or Very sad
_________________
( •_•)

( •_•)>⌐■-■

(⌐■_■)

YEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH

Post Fri Feb 03, 2006 10:54 am 
 View user's profile Send private message Visit poster's website MSN Messenger
DumHed
Experienced Roboteer


Joined: 29 Jun 2004
Posts: 1219
Location: Sydney


 Reply with quote  

the good thing is this stuff looks like work to people here Razz
_________________
The Engine Whisperer - fixer of things

Post Fri Feb 03, 2006 11:17 am 
 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 1 of 4

Goto page 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.