|Feb 15, 2013, 01:51 PM|
Joined Mar 2006
Picaxe Mirocontrollers. An impecunious oraman's introduction.
Picaxe microcontrollers are Pic chips pre loaded with a Basic Interpreter.
Programming is done down 3 wires from a 9pin serial socket or USB at one click.
They are the simplest, cheapest introduction to micros.
The simplistic program below uses 28 out of the 2048 bytes of the
8pin Picaxe 08M2, uses only 5 instructions and is fast enough to reliably
read pulses from receivers.
There is a mountain of information on the Picaxe site but only about 20
instructions are needed for control programmes such as servoslowdown and mixers.
As an example this question was Posted in 2009 ~~~~~~~~~~~~~
3 position rc electronic switch schematics?
Is there a circuit somewhere thats 3 position? (ON, OFF, ON) to turn on two
different things, and a neutral off for both of them.
For example: Move the stick forward it turns one relay to "ON", but when you
pull the stick back it turns a different relay to "ON" and neutral stick position
is "OFF" for both relays.
You could download the free Picaxe Programming Editor, select 08M2, copy and
paste this simplistic program,Click Simulate, change Generic to 100, 150, 200,
100 repeatedly and observe the action.
If I can help?
'Stick centre pulse is 150. (') = comment :defines place Label START: '.A destination for jumps within the program pulsin 3,1,b2 '.RX on GPIO3, pin 4 on the chip into variable b2 if b2 < 130 then goto LEFT '......jump if b2 is less than 130 if b2 > 170 then goto RIGHT '...........jump if more than 170 low 2 '............TX stick is at centre, cancel earlier action low 4 '............TX stick is at centre, cancel earlier action goto START '............ .jump to START and await next RX pulse LEFT: '.............................................another label high 2 '.............................+5V on GPIO2 on chip pin 5 goto START RIGHT: high 4 '.............................+5V on GPIO4 on chip pin 3 goto START
|Feb 15, 2013, 02:34 PM|
Good stuff. Seems very easy to implement and write code. A few questionsif I may:
|Feb 15, 2013, 03:24 PM|
My first development boards is a picaxe and the language is pretty straightforward. I switched over to Arduino because of the large community support, and availability of accessories available for it, more pug and play if you will. The picaxe predates the ATMega32 chip based arduino.
I do like the Picaxe though, and it will be part of my evolving knoweldge base.
the serial connection I find is a bit of a pain in the butt personally, using a regular Dsub-9 that is. but a programing port and cord for a Picaxe can be easily fabricated with an old mini headphone jack, plug and cord and a barebones Dsub-9 plug.
I think the Propeller boards are the Picaxe equivalent of a Arduino.
|Feb 15, 2013, 04:09 PM|
Joined Mar 2006
My only use of I2C has been the DS18B20 Temperature Sensor with the Readtemp or Readtemp12 commands.
The syntax being ~~
Conversion takes up to 750ms but flawless and reliable.
I am using an ADC to read a pot for setpoint.
A proportional burst output to a zero crossing SSR into a remote 240v heater.
One DS18B20 reading ambient
Another DS18B20 has a resistor tight against it's underside and it's leads for good thermal transfer.
Via a transistor the resistor is heated with the same output as the SSR so that this DS18B20 should render an analogue of the heat in the remote heater. Feedback with the ambient reading will require further testing and a look-up table. Work in progress but looking good.
There are another half dozen I2C instructions in Manual 2.
I have found it comparatively easy to use Picaxe together, even powering one from another if within the 25ma from a pin.
Or have I picked you up wrongly?
|Feb 15, 2013, 05:22 PM|
posting from your Iphone craig? that email thing took me right to the lite version, or mobile site on my laptop :P
but yes, you are correct, geeks tend to talk in geek speak, esppecially when dealing with other geeks, and the point of it all is to dispell all this... stuff into something a laymen can understand, apperciate, make use of, and quite possibly steal code for simular projects that can be modified to suit needs.
if any of us get a little too geek speak and if anyone asks us just what the heck we are talking about, we should be prepared to explain our selves in a less technical fashion and be able and willing to expond on that notion if asked.
|Feb 15, 2013, 05:36 PM|
Also, if one posts code, it should be annotated.. as orraman did in his first post.. an explination in the code line, to explain what the bit of code does, very helpful for the person learning, or, god forbid, the poor tech that has to come up behind the original tech to fix problems down the road. all my code back in my PLC days was annotated. because sometimes, the tech coming in to fix the problem maybe your, and time is money, so dont waste half your time deciphering the code to people talk!
also K.I.S.S. not the rock group band, but the philosophy... Keep It Simple, Stupid. that alsowill help stream line your code, and keep a small footprint which is critical in these small environments.
|Feb 16, 2013, 07:15 AM|
Joined Mar 2006
Gentlemen, Thank you,
Sorry for giving you duff information, I had used the DS18B20 (one wire temperature sensor) in the paint by numbers system straight out of Picaxe Interfacing Manual3.
In defence I can say that I looked at the google headlines before replying and misread the confusing results.
Prattling on about temperature got me thinking about Profmason's Picaxe pages.
But you will need to scroll down past his perfectly detailed
Picaxe based LiIon Battery Charger
Picaxe Pong Sat Mk1 ....................to get to his
Picaxe 08M Datalogger using an LM35 Temperature Sensor with the instruction ~~
Picaxe variables are in pairs of two 8 (binary) bit bytes each capable of holding numbers 0 to 255 decimal.
So that variable b0 and variable b1 when combined become the 16 bit word w0 holding numbers 0 up to 65535 decimal.
But each of these byte variables b0 and b1 is still available separately while still being available as w0.
The Readadc (pin), b4 instruction would put the 8 most significant bit values into the byte variable b4 and the fine detail would be discarded.
Readadc10 (pin, here named adc) w0 puts the 10 bit value available into b0 and b1 with the finer detail (least significant) into b0. So by reading 10 bits into a two byte word and then taking the lower byte the finer detail is saved.
This effectively amplifies the signal voltage being read.
Consider the program in Post #1 being used to move a gun turret with a DC motor, limit switches are a pain and a potential source of problems. The voltage to the motor could be reduced to the point where stalling would not damage the motor by overheating but this would require a bigger motor than needed.
If a resistor is in series with the motor the current flowing through the resistor will cause a voltage to be developed across it's terminals.
This voltage could be fed to an ADC, analogue to digital converter in the Picaxe.
Readadc10 pin,w0 '.............................voltage across resistor into word variable w0
if b0 > safe value, then stop motor '.......taking the low byte with it's greater sensitivity allows a smaller resistor value, less heat and less wasted power.
|Feb 18, 2013, 04:44 PM|
Joined Mar 2006
It is comparatively easy to control servos with a Picaxe using the instruction Servo to initiate the function and subsequently the instruction Servopos as this does not interfere with the internal timer and so avoids jittering.
Servopos runs in the background, allowing other tasks to be performed and is only used when a change of position is required.
GPIO is the nomenclature of Microchip, General Purpose Input Output pin arrangement.
servo 4,100 '.....................initialise a servo on GPIO4 = pin3
servopos 4,100 'After first "servo" use servopos to keep timer happy
high 2 '....................................5v on GPIO2 light up LED
pause 1000 '..................................keep LED on for 1000ms
low 2 '................................................. .....LED off
servopos 4,200 '....................................reposition servo
pause 2000 '.................................Keep LED off for 2000ms
goto main '..........loop to main and servopos continuously
'Memory used = 24 bytes out of 2048 08M2 copy and paste in simulator
There is another way to constantly control a servo particularly when the Picaxe is receiving servo pulses from an RC receiver.
From the program in Post #1 Perhaps for dropping 2 anchors,
'TX stick to be centered = 150
'TX stick left will drop one anchor
'TX stick right will drop second or both anchors
START: '............A destination for jumps within the program
pulsin 3,1,b2 '......RX pulse on GPIO3, pin 4 into variable b2
if b2 < 85 or b2 >220 then start '.reject pulses outside range
if b2 < 130 then goto FIRST '......jump if b2 is less than 130
if b2 > 170 then goto SECOND '................if more than 170
pulsout 4,100 '....servo at left holding 2 anchors awaiting TX
goto start '.....TX stick is centered. Picaxe await next pulse
FIRST: '................servo moves to centre, drop one anchor
pulsout 4,150 '....}pulses are timed by the Transmitter so are
goto START '.......}already at the proper RC frame rate ~ 20ms
pulsout 4,200 '.servo moves to right, drop last anchor or both
|Feb 18, 2013, 05:53 PM|
United States, PA
Joined Feb 2013
So not all PIC microcontrollers have this same language, only the ones from picaxe, correct? I did a search looking for PIC and radio, and one site I found shows some tutorials but the code looks like it is all C. IS it possible to use a PIC with basic instead of C to talk to a radio? The basic you are using looks so much easier.
|Feb 19, 2013, 10:08 AM|
Joined Mar 2006
Greetings H D,
Pic microcontrollers are made by Microchip who have low level assembler software which gives the greatest possible control of all the capabilities of their micros and programs run at the speed of the processor.
Expect to take a year or so to become competent in programming in assembler language as this requires intimate understanding of the architecture and functionality of each micro and it's Data Sheet.
C is a high level language, using a semblance of English and many control codes, the program is compiled into assembler close to native Pic assembler and run at processor speed. A good understanding of the architecture and functionality of the chip is required.
Basic is high level language in a form of stilted but understandable English.
Compiled Basics such as Proton Basic require some understanding of the architecture and functionality of the chips, programmes run at processor speed but may not handle interrupts at machine level.
All of the above require a hardware programmer to load the program into the micro unless a bootstrap is used but the bootstrap has to be programmed with a programmer. A good working knowledge of the compiler and how it handles software fuses is needed.
Interpreted Basic such as Picaxe Basic is near to spoken English and great effort has been made to make it easy to use.
The manuals have simple diagrams showing the functions available on each size of Picaxe, Pic architecture and Data Sheets are neither mentioned or needed.
Smaller Picaxe run at between 4MHz and 32MHz but interpreting the code takes time so instruction execution is in the order of some 100,000s per second and this is more than sufficient for the great majority of RC functions. Interrupts are software interrupts where the end of each line of code is checked for an interrupt.
My experience has been of normal model radio control and the second program in the previous post functioned properly with Futaba equipment.
Picaxe have 2 pages of wireless modules that are available to suit Picaxe micros.
|Feb 20, 2013, 08:07 AM|
Joined Mar 2006
Morse Code Beacon
Morse Code Beacon
Only thing that I can add to this is that the current Picaxe 08M2 has 4 times the memory of the Picaxe 08M used in this project.
|Feb 21, 2013, 02:09 AM|
Joined Mar 2006
Shortest 1 second FLASH routine?
Start: toggle 1 '...alter state high/low LED on GPIO1,pin6
pause 500 '.........hang about for 1/2 second
goto Start '.........repeat flash every second
|Category||Thread||Thread Starter||Forum||Replies||Last Post|
|Discussion||Help, S.O.S., ..._ _ _... (and introduction)||sajosa||Electric Plane Talk||15||Feb 28, 2013 02:00 AM|
|Discussion||How to wire an ESC to picaxe.||keffa12||DIY Electronics||9||Apr 02, 2011 10:44 AM|
|Brushless Motors -- An Introduction...||rc_ron||Power Systems||1||Aug 06, 2004 12:18 PM|
|Suggest an introduction ducted jet ARF?||bwaltz||Electric Ducted Fan Jet Talk||2||Aug 23, 2002 07:50 PM|