Struggling to understand PICAXE (noob)

markus79

New Member
Hi everyone, I'm very new to electronics, but have been developing software for almost 10 years. I can't believe how much more difficult this is than software development! I'm having a hard time with simple circuitry, so I thought I couldn't fail with PIXAXE - One programmable chip and loads of possibilities!

However, I'm having a really hard time getting an 08M2 to work on my breadboard, so I have a couple of questions for y'all to mock. I have read the documentation of course and tried to find answers in this forum, on other pages and watched a bunch of youtube videos. I'm still uncertain, please forgive my noobness.

1) Powering the 08M2 on a breadboard

I have tested 3xAA and wall socket regulator (5V) and I get the corresponding voltage across pins 1&8. I can flash an LED using the simplest of programs, but anything else is completely unstable and utterly useless. As soon as I start using variables (symbols) in the programming, the chip behavior is very unpredictable. Servos respond after 10+ seconds, sometimes not at all or when they shouldn't.

Question: Do I have to use any specific capacitors or resistors when I just want to run a program? I have read somewhere that the serial IN should be grounded or the program won't run, but is this only during download? What is the absolute simplest way to power a project?

2) Inputs and outputs

I've read in the manual how to connect a switch input. +V to 0V with a 10K resistor and somewhere in-between draw a line into the 08M2. I've also (unknowingly) drawn +V straight into the chip, which
seems to work (I think), but I'm not sure since the chip behavior is so erratic.

Question: Since blinking an LED gets the +V from the chip, do I have to connect inputs to 0V anyway?


I having a really hard time with the results, when I was totally looking forward to a "problem-free" chip interface, please can someone shed some light on this? Thank you all! :)


PS: About half the times I try a download, it fails with "Hardware not found". It's like the download only succeeds on chance. Even though I read another thread on this, I'm not sure what to make of it. The download board works, then it fails, then works again.. Sometimes I just have to restart MacAxePad.. So unstable. :(
 

lbenson

Senior Member
1) post your circuit

2) grounding of serin is always required, otherwise chip will reset erratically, which could well be causing the problems you see.
 

nick12ab

Senior Member
Question: Do I have to use any specific capacitors or resistors when I just want to run a program? I have read somewhere that the serial IN should be grounded or the program won't run, but is this only during download? What is the absolute simplest way to power a project?
Use a 10K resistor between Serial In and 0V at all times.

Question: Since blinking an LED gets the +V from the chip, do I have to connect inputs to 0V anyway?
Yes.
 

westaust55

Moderator
The minimum circuit for the 8 pin PICAXE parts is shown in manual 1 at page 27:
http://www.picaxe.com/docs/picaxe_manual1.pdf#page27

The resistors for the download circuit on the serial min pin must always be present for programming and the serialIn pin must alway be pulled low at power up otherwise the PICAXE firmware thinks that a new program is being downloaded and will not run the already downloaded program. (Serial in can be used as an input only after the DISCONNECT command has been executed).

For a simple circuit a 100 nF ceramic decoupling capacitor is all that is required.

When using 3 x AA cells, the batteries need to be fresh.
A primary cause of programs failing to download is due to low battery voltage. The PICAXE are better able to run at lower voltage than to program at lower voltages.

Other than the SerialIn pin it is not mandatory that unused inputs are pulled or tied to 0 Volts. Personally I do not but others do recommend pulling unused pins low.
Connections for switches to inputs is Shown in PICAXE manual 3.
 

premelec

Senior Member
FWIW - any LEDs directly controlled from a PICAXE pin must have a series current limiting resistor [internal or external] or the pin current will be too high and perhaps pull the V+ down as well.
 

hbl2013

Senior Member
PS: About half the times I try a download, it fails with "Hardware not found"........ :(
I have had this problem with several other chips (18M2, 20M2, 28X2, 40X2) and posted about it. I have more than a dozen chips, that will not program anymore after displaying that message. They were used on different computers, different circuits and different hardware layouts, so I came to the conclusion that I did something that caused the chip to become inoperative.
Unfortunately, I have never been able to determine what it was. (I had this problem with circuits I build myself and with Development Boards like the axe117, axe118 or ch1030A)
It was suggested that the cause might lay in the program I wrote, but I can not see what the program has to do with the hardware functions of the chip. However, I do not know enough about the structure of the chip to completely dismiss this suggestion.
I am still looking for a solution to this problem.
 

kranenborg

Senior Member
Hej Markus!

Kul att träffas (jag är tillbaka in Nederländerna efter en 10-års vistelse i Sverige ...)!

In case you feel more secure with software than with hardware, it is good to have a stable hardware base that you can turn to in case things turn out differently for your hardware project. For me the AXE092 Schools Experimenter Board has been my long-time favorite for the 08M2 as it it extremely flexible by providing access to all i/o pins but also can have all 5 i/o pins connected to something useful on the board. The DIP-switch on it allows to connect-disconnect them and thus this board could be connected to your project for testing purposes to guarantee that the base stuff (08M2 + power + download circuit + decoupling caps) always works. In that way it will be easier to search for hardware-related issues on your particular board. Also, the fact that it can be battery powered removes the Vcc noise issue from the problem analysis. Finally, if you think that you may have damaged a chip, you can test it on the board with a simple program to verify its functionality.

PS: In general I have found the 08M2 to be very stable and dependable to use, but as several contribuants have remarked there are a number of things that need to be properly done for each project (download circuit installed, decoupling caps). As a last remark: in case you want to ground unused inputs (which is not strictly necessary but reduces power consumption) always use a resistor to tie them to GND (pref something like 10K): for inputs/output pins a programming error on such a pin (putting such a pin at High) would shortcdirciut the port and probably damage it.

MVH,
Jurjen
http://www.kranenborg.org/electronics
 
Last edited:

papaof2

Senior Member
I have had this problem with several other chips (18M2, 20M2, 28X2, 40X2) and posted about it. I have more than a dozen chips, that will not program anymore after displaying that message. They were used on different computers, different circuits and different hardware layouts, so I came to the conclusion that I did something that caused the chip to become inoperative.
Unfortunately, I have never been able to determine what it was. (I had this problem with circuits I build myself and with Development Boards like the axe117, axe118 or ch1030A)
It was suggested that the cause might lay in the program I wrote, but I can not see what the program has to do with the hardware functions of the chip. However, I do not know enough about the structure of the chip to completely dismiss this suggestion.
I am still looking for a solution to this problem.
If your program is in a very tight loop, it cam miss the state change when the Program Editor starts a new download. To bypass this ude the recommended sequence: turn power OFF to the PICAXE chip, start the download then turn power ON to the PICAXE. This has always worked for me.
 

rq3

Senior Member
PS: About half the times I try a download, it fails with "Hardware not found". It's like the download only succeeds on chance. Even though I read another thread on this, I'm not sure what to make of it. The download board works, then it fails, then works again.. Sometimes I just have to restart MacAxePad.. So unstable. :(
Well, personally, I have a mass programming unit that uses the Rev-Ed cable, and a 3mm socket to accept the plug at the end of the cable. The socket is flakey, so when I get the "hardware not found", I rotate the plug 90 degrees in the socket and try again. Sometimes it takes a few attempts. It's obviously a bad contact, and I'm too lazy to fix it, since I know where the problem is, and how to "fix it".

The moral of the story is: check your connections, all of your connections.
 
Last edited:

markus79

New Member
Thank you ALL for your tips!

I wrote a very small test, just to see if I could wrap my mind around what is happening and I think I'm going crazy. The following program SHOULD NOT BLINK:

Code:
symbol ready = w0

main:
	let ready = 0
	do
		if pinC.3 = 0 AND ready = 0 then
			let ready = 1
			high C.2
			pause 2000
		else if pinC.3 = 1 AND ready = 1 then
			let ready = 0
			low C.2
			pause 2000
      	endif
	loop
stop
As soon as the chip is programmed using the PICAXE-08M2 Starter Pack (USB), it starts blinking with 2 second intervals. It stops when I connect C3 and resumes blinking a full 10 seconds after I disconnect C3. What is happening here? It's like C3 is turned on whenever C2 is high? Why does it pause for 10 seconds?

I later tested the same chip on the breadboard and the program WORKS FINE (led turns off for 2 seconds after a quick push of the button). The breadboard has SIN grounded with a 10K resistor (no capacitors). It therefore seems like the programming chip is malfunctioning badly.
 

hippy

Technical Support
Staff member
It stops when I connect C3 and resumes blinking a full 10 seconds after I disconnect C3. What is happening here?
What is your full circuit, what are you connecting C.3 to and how ?

It sounds like you have a floating C.3 ( push button but no pull-up or pull-down ) which is proving more problematic in your programming board than it is on breadboard.
 

markus79

New Member
What is your full circuit, what are you connecting C.3 to and how ?

It sounds like you have a floating C.3 ( push button but no pull-up or pull-down ) which is proving more problematic in your programming board than it is on breadboard.
I'm not sure what you mean by "no pull-up or pull-down"? I've read "floating" somewhere else, but could you care to explain?

I have connected V+ to 0V with a 10K resistor and drawn a wire into C.3 (just like connecting a switch as per the manual). The voltage is the same as between pins 1 and 8.

I then removed that connection and now ONLY have PICAXE -> C.2 OUT -> LED -> 1K -> 0V and it still blinks. :confused:

Do you mean I have to connect every other output through a resistor to ground?
 

hippy

Technical Support
Staff member
You have to connect all inputs used in a program to +V or 0V, either directly or through a resistor, otherwise the input will be floating ( not connected to either +V or 0V ) and the input value read will be random and indeterminate; it will sometimes read high, it will sometimes read low.

If you have the code in post #11 and nothing connected to input C.3 you will get unpredictable behaviour and potentially the behaviour as described.
 

markus79

New Member
You have to connect all inputs used in a program to +V or 0V, either directly or through a resistor, otherwise the input will be floating ( not connected to either +V or 0V ) and the input value read will be random and indeterminate; it will sometimes read high, it will sometimes read low. If you have the code in post #11 and nothing connected to input C.3 you will get unpredictable behaviour and potentially the behaviour as described.
Ok, didn't know that, thanks!

I connected C.3 to 0V and the LED from C.2 stopped blinking, but there was NO 2s DELAY when I connected +V to C.3, instead the LED instantly turned OFF (and ON when I disconnected +V from C.3). Really odd. :confused:

I've also tried changing to ports C.1 and C.2 instead and I get the exact same result. This would indicate that I'm probably missing something (not hardware fault). Any more ideas? Thank you for your help!
 

hippy

Technical Support
Staff member
I connected C.3 to 0V and the LED from C.2 stopped blinking, but there was NO 2s DELAY when I connected +V to C.3, instead the LED instantly turned OFF (and ON when I disconnected +V from C.3). Really odd. :confused:
Possibly because the 2 second period for being on had just expired; you haven't actually implemented a delay from when the pin changes, and if the pin is floating while moving the connection from 0V to +V then that could cause some issues as well.
 

markus79

New Member
It is now working.

I added a 1K resistor to the "switch" again and it is now working as expected.

Thank you all for your help!

Basically, I was missing 0V + 10K to Serial-IN and 0V + resistor to other IN-ports. I've read that other users recommend grounding all ports, which I now see could be good for eliminating bugs.

Hopefully I'll get the servos working shortly! :)
 

westaust55

Moderator
I had mentioned at post 5 that switches must be connected as per PICAXE manual 3.
See page 26: http://www.picaxe.com/docs/picaxe_manual3.pdf#page26

The 10 kOhm resistor shown on that page is the pull-down and pull-up resistor mentioned by hippy which prevents the input from floating where the voltage may drift up and down changing the state between a "0" and a "1".

Providing a schematic /circuit diagram of the circuit in question can be very helpful in tracking down hardware related problems more quickly.
 

markus79

New Member
Ok, servo motor is silent. No action whatsoever using the program below, connected to C.1 with a 330R between pin and yellow wire on servo (as suggested in the manual). Light on C.2 works without any problem.

Code:
symbol ready = w0

init:
	let ready = 0
	servo C.1, 0

main:
	do
		if pinC.3 = 0 AND ready = 0 then
			let ready = 1
			high C.2
			servopos C.1, 0
			pause 2000
		else if pinC.3 = 1 AND ready = 1 then
			let ready = 0
			low C.2
			servopos C.1, 30
			pause 2000
      	endif
	loop
stop
Is there anything I should be trying in the code? Is it likely the motor itself is dead? (I have run it before, but might have burned it like I did another motor, how can I be sure?)
 

hippy

Technical Support
Staff member
Start with simpler code, for example ...

Code:
Servo C.1, 0
Do
  ServoPos C.1, 0  : Pause 2000
  ServoPos C.1, 30 : Pause 2000
Loop
Get that controlling the motor before trying to control it with a button input and more complicated software.
 

markus79

New Member
Start with simpler code, for example ...

Code:
Servo C.1, 0
Do
  ServoPos C.1, 0  : Pause 2000
  ServoPos C.1, 30 : Pause 2000
Loop
Get that controlling the motor before trying to control it with a button input and more complicated software.
I did that too (just now). Nothing. Motor is probably dead.
 

hippy

Technical Support
Staff member
I did that too (just now). Nothing. Motor is probably dead.
Could be. Could be a wiring issue or something else. Perhaps it just needs different SERVOPOS values. Details of the motor being used, photos of the setup, may help others give their opinion on what's likely to be the problem.
 

hbl2013

Senior Member
To bypass this ude the recommended sequence: turn power OFF to the PICAXE chip, start the download then turn power ON to the PICAXE. This has always worked for me.
Tried that, does not work. Sometimes substituting the chip will work. (This is odd, because the replacement chip displayed the same problem before, and now works suddenly normal.), But sometimes it does not.
Frankly, it drives me batty!
 

westaust55

Moderator
With respect to Servo motors, you may find the tutorial I posted some years ago to be helpful:
http://www.picaxeforum.co.uk/showthread.php?12120-A-Basic-Servo-Tutorial&p=96648#post96648

If you are having ongoing problems with reprogramming PICAXE chip the usual valses are:
1. Power voltage to PICAXE too low - when using 3 x AA cells that are nearing end of life
2. The program has a tight loop or long pause that prevents the PICAXE chip "seeing" the signal to initiate a new download
3. An intermittent fault in wiring or bad breadboard connection.
 
Top