Read statement maximum voltage

technokid

Member
Hi all,

I am building a small, 3 wheeled robot to take sensor readings, blink, make noise, etc.
I have a remote controlled car that I have taken apart and I wanted to use the R/C circuitry to control it from afar.
It works, and I am ready to connect it to my robot, but before I did, the motor out pins (I am using that to connect to the 20M2) read 5V.
I took the motors off and was going to connect the left over pins to the input pins on my robot.
I was wondering, what is the maximum voltage that the PICAXE can read.
I have a feeling that it is the same voltage as the power supply to the PICAXE (Regulated 5V), but I want to make sure, to make sure that I don't "kill" the chip.
The "BASIC Command" section of this site doesn't tell me the voltage, only what "Read" does.
I only want to read a digital voltage from the remote control unit

Please help.

Technokid.

P.S Does anyone know how to make a cheap, simple, wireless unit to replace the R/C unit if possible (It is bulky and confusing)
 

Dippy

Moderator
Without special precautions don't take the input voltage above the supply voltage - as you have said.

If you think this may happen (even a spike) then come back here for more advice.
There are several ways to protect/limit the input.
If you want that advice please let us know and people can describe the methods.
They are, like me, very simple :) (The methods, not the people).

HOWEVER, I would suggest that you post a (tidy and readable) schematic so that experienced eyes can double-check.

Slight aside: I was going to suggest looking at Manual 1 "Ata glance - specifications"; "Inputs" and "ADC".
The 'maximum' doesn't get a mention. Not even a warning.
In my view a serious omission for those that read manuals.

One final tip: if you want full and proper electrical data then get the Microchip Datasheet from their site.
It may be a chore to read BUT it does give the full and latest electrical data... including the full answer to the question you asked.
 

srnet

Senior Member
P.S Does anyone know how to make a cheap, simple, wireless unit to replace the R/C unit if possible (It is bulky and confusing)
A small RC unit, of which there are many.

However 'small' and 'bulky' means different things to different people so could you provide some more details of what size or weight you were looking for ?
 

technokid

Member
Mainly anything under 5cm x 5cm x 10cm. As for simple, I mean anything that easily connects to the picaxe to receive serial data through an input pin.
Also, I know that there is an infra-red remote that is PICAXE compatable, and IR has its own "code mention" (Infrain, IRout, etc), but is there a "code mention" for the RC unit (communications)?
 

BeanieBots

Moderator
......is there a "code mention" for the RC unit (communications)?
Sort of.
The servo motors used in models all respond to a pulse of a specified width.
They can be driven by the "servo" command.
The bit between buttons and joysticks over the air and decoding to a servo pulse is unique to each manufacturer (or you if you want your own).
If you do it with PICAXE, then you have many options. Use the IR commands, RFin/RFout or serial data.
It will depend on how you choose to send the data through the air.
 

technokid

Member
Thanks for that but I have a problem.
I ran out of pins for my robot and used a 08M2 chip as a slave by reading serial data through pin 2 but when I ran the program, it came up with "Syntax error on this line (line 3).
Would anyone know how to fix this?

Code:
Start:
serin 2,N2400,W0
If W0 = "Pin0on" then goto pinaon
If W0 = "Pin0off" then goto pinaoff
If W0 = "Pin1on" then goto pinbon
If W0 = "Pin1off" then goto pinboff
If W0 = "Pin1read" then goto pinbread
If W0 = "Pin1readadc" then goto pinbreadadc
If W0 = "Pin3read" then goto pindread
If W0 = "Pin3readadc" then goto pindreadadc
If W0 = "Pin4on" then goto pineon
If W0 = "Pin4off" then goto pineoff
If W0 = "Pin4read" then goto pineread
If W0 = "Pin4readadc" then goto pinereadadc
If W0 = "Pin5read" then goto pinfread
If W0 = "Pin5readadc" then goto pinfreadadc
goto start

pinaon:
high 0
goto start

pinaoff:
low 0
goto start

pinbon:
high 1
goto start

pinboff:
low 1
goto start

pinbread:
read 1,b0
serout 2,N2400,b0
goto start

pinbreadadc:
readadc 1,b0
serout 2,N2400,b0
goto start

pindread:
read 3,b0
serout 2,N2400,b0
goto start

pindreadadc:
readadc 3,b0
serout 2,N2400,b0
goto start

pineon:
high 4
goto start

pineoff:
low 4
goto start

pineread:
read 4,b0
serout 2,N2400,b0
goto start

pinereadadc:
readadc 4,b0
serout 2,N2400,b0
goto start

pinfread:
read 5,b0
serout 2,N2400,b0
goto start

pinfreadadc:
readadc 5,b0
serout 2,N2400,b0
goto start
 

geoff07

Senior Member
It may be the quotation marks. The more common way of coding what you want would be:
Code:
symbol C_pin0on = value1
symbol C_pin0off = value2
do
   select W0
      case C_pin0on: high 0
      case C_pin0off: low 0
      ...
   endselect
loop
The symbol statements give a value to the names; the 'C_' is my way of making clear which names are of constants; there is no need for the gotos at all. The values of the constants are irrelevant so long as each is unique. Unless you have more than 255 situations to check you could save a byte with the use of b0 instead of W0. This will execute faster, on average, than your original as it will not do all the tests.
 

technokid

Member
I tried the script with the numeric variables instead. It works.
Also, I forgot to put brackets around the variable on the serout commands.
The script now looks like this:

Code:
Start:
serin 2,N2400,b0
If b0 = 01 then goto pinaon
If b0 = 00 then goto pinaoff
If b0 = 11 then goto pinbon
If b0 = 10 then goto pinboff
If b0 = 12 then goto pinbread
If b0 = 13 then goto pinbreadadc
If b0 = 32 then goto pindread
If b0 = 33 then goto pindreadadc
If b0 = 41 then goto pineon
If b0 = 40 then goto pineoff
If b0 = 42 then goto pineread
If b0 = 43 then goto pinereadadc
If b0 = 52 then goto pinfread
If b0 = 53 then goto pinfreadadc
goto start

pinaon:
high 0
goto start

pinaoff:
low 0
goto start

pinbon:
high 1
goto start

pinboff:
low 1
goto start

pinbread:
read 1,b0
serout 2,N2400,(b0)
goto start

pinbreadadc:
readadc 1,b0
serout 2,N2400,(b0)
goto start

pindread:
read 3,b0
serout 2,N2400,(b0)
goto start

pindreadadc:
readadc 3,b0
serout 2,N2400,(b0)
goto start

pineon:
high 4
goto start

pineoff:
low 4
goto start

pineread:
read 4,b0
serout 2,N2400,(b0)
goto start

pinereadadc:
readadc 4,b0
serout 2,N2400,(b0)
goto start

pinfread:
read 5,b0
serout 2,N2400,(b0)
goto start

pinfreadadc:
readadc 5,b0
serout 2,N2400,(b0)
goto start
I coded it so that the first digit is the pin.
The second digit is the function. 0 to turn off, 1 to turn on, 2 to read pin and 3 to read an analog voltage.
Works nice on the simulator.Hopefully, it will work on my robot.
Thanks all.

Technokid

P.S pinbread, for example, means pin b in the program (in this program, pin 1), and to digitally read that pin and send the data back to the main/other chip.
 

AllyCat

Senior Member
Hi,

Code:
serin 2,N2400,b0
;.........
pinbread:
read 1,b0
serout 2,N2400,(b0)
goto start
READ 1,b0 doesn't read a PIN it reads an EEPROM memory location! For clarity, it would be better if you used the port.pin notation (although the PE still won't necessarily pick up "unintended" commands as errors). A #PICAXE xxM2 command at the top would help show which processor is intended to run the code.

Also, you appear to be reading and writing serial data on the same pin? :confused:

Cheers, Alan.
 
Top