Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PICAXE not working?

Status
Not open for further replies.
This could be correct if above code dont work.
Code:
CODE REMOVED TO SAVE CONFUSION

Pete.
 
Last edited:
Then i might be backwards to.

Can you tell me is the output from the 311 meant to turn the motor on or is it turn the motor off.
What is the switch meant to do.
I forget the actual procedure how this function now please refresh me.

Pete.

Hey,

When Input4(pin3 of the 08M) is High and Input3(pin4 of the 08M) is Low the the motor should be ON.

Input3 (pin4 of the 08M) is where the output of the 311 is connected, so when the 311's output is LOW then the Motor should be ON (assuming Input4 of the 08M is High as well).

Hope that resolves any confusion about what should be happening. My problem is that when the output of the 08M is supposed to be HIGH (to turn the motor ON) its NOT High (even when Input4=High and Input3=Low).
 
This could be correct if above code dont work.
Code:
main:
 
if input4 = 0 AND input3 = 0 then 
high 2  ;gas and switch ON, wait 12s and Motor ON
pause 200
endif 
 
if input4 = 1 OR input3 = 1 then 
low 2  ; gas OR switch OFF, Motor OFF - if the flame is on in the middle 
pause 200
endif 
 
goto main

Pete.

OMG that actually worked!

I even tried connecting the motor to the terminals and it worked when both inputs were LOW, but when they were both HIGH it stopped working as expected. I also checked the output of the 08M and it worked as expected!

So, our problem is definitely with the code, it seems like the FET is doing its job and all the circuitry after the chip is working...

Now how do we program it in the way that it waits 12s before output2 is High? while making sure that it's only High when Input4=1 and Input3=0? Basically, I want to implement the flow chart in my previous post...
 
Last edited:
this is really annoying...when I change the code I get the output as LOW at all times... I changed the code only slightly to the following:

Code:
main:

if input4 = 0 then
low 2  ; gas OR switch OFF, Motor OFF - if the flame is on in the middle 
pause 200
endif 
 
if input4 = 1 AND input3 = 0 then 
pause 12000
high 2  ;gas and switch ON, wait 12s and Motor ON
endif 

if input4 = 1 AND input3 = 1 then 
low 2  ; gas OR switch OFF, Motor OFF - if the flame is on in the middle 
pause 200
endif 
 
goto main
 
This should give you something to start off with that will be close to what you want, i tried to keep it simple so you can follow rather than do some fancy sort of code you might not understand

The reason it waits 1 second and then goes through the for/next loop 12 times is so the input pins can be checked each second rather than to wait for 12 seconds to detect any change.

The code was a lot simpler but i need to change it because if you had run the code in the simulator it filled the stack and gave an error, even though in real life it would not have mattered and worked fine.

This version runs fine in the simulator, give it a go and you should see how it functions, remember pin3 = 0 and pin4 =1 for it to enter into the 12 second counter to turn the motor on, if you change pin3 or pin4 while its counting the 12 seconds, it will abort and go back to main.

See how you go and report back with the results.

Pete.

Code:
CODE REMOVED TO SAVE CONFUSION
 
Last edited:
Whoops...................
I had pin3 and pin4 backwards above.

TRY THIS ONE............

Code:
CODE REMOVED TO SAVE CONFUSION
 
Last edited:
Whoops...................
I had pin3 and pin4 backwards above.

TRY THIS ONE............

Code:
symbol switch_1 = pin4
symbol C_311 =    pin3
symbol motor =    2
symbol Y =        b1

main:
 
	if C_311 = 1 AND switch_1 = 0 then Delay 

 
	if C_311 = 0 OR switch_1 = 1 then 
	low 2  ; gas OR switch OFF, Motor OFF - if the flame is on in the middle 
	endif 
 
	goto main

Delay:
	for Y = 0 to 11
	wait 1
	if C_311 = 1 AND switch_1 = 0 then
	next Y
	endif
	
	
	if C_311 = 1 AND switch_1 = 0 then 
	gosub Gas_on
	endif
	
	goto main 
	
	
Gas_on:
	
	high 2  ;gas and switch ON, wait 12s and Motor ON
	return

I tried it by having input4 High (4.45v) and input3 Low (0.10v) and the output was LOW (0v) (why is it still not working!?).
I changed the code slightly though to make sure that when input4 was High and input3 was Low that the output2 was supposed to be high...

Still not working..

Code:
symbol switch_1 = pin3
symbol C_311 =    pin4
symbol motor =    2
symbol Y =        b1
 
main:
 
	if C_311 = 1 AND switch_1 = 0 then Delay 
 
 
	if C_311 = 0 OR switch_1 = 1 then 
	low 2  ; gas OR switch OFF, Motor OFF - if the flame is on in the middle 
	endif 
 
	goto main
 
Delay:
	for Y = 0 to 11
	wait 1
	if C_311 = 1 AND switch_1 = 0 then
	next Y
	endif
 
 
	if C_311 = 1 AND switch_1 = 0 then 
	gosub Gas_on
	endif
 
	goto main 
 
 
Gas_on:
 
	high 2  ;gas and switch ON, wait 12s and Motor ON
	return
 
You are mixing up the various lots of code and using the incorrect pin labelled code to modifie.
It is this one you should be using. TRY IT AGAIN!!!

Code:
'THIS VERSION 0005 BY SABORN

symbol switch_1 = pin4
symbol C_311 =    pin3
symbol motor =    2
symbol Y =        b1
 
main:
 
	if C_311 = 0 AND switch_1 = 0 then Delay 
 
 
	if C_311 = 1 OR switch_1 = 1 then 
	low 2  ; gas OR switch OFF, Motor OFF - if the flame is on in the middle 
	endif 
 
	goto main
 
Delay:
	for Y = 0 to 11
	wait 1
	if C_311 = 0 AND switch_1 = 0 then
	next Y
	endif
 
 
	if C_311 = 0 AND switch_1 = 0 then 
	gosub Gas_on
	endif
 
	goto main 
 
 
Gas_on:
 
	high 2  ;gas and switch ON, wait 12s and Motor ON
	return

Can you tell me in English how this system is meant to operate, dont worry about pin numbers just the human operation, as you would for telling me before you had built the circuit.
I am still somewhat confused over how all this operates and trying to write code with guessing what i think is correct.

The code works fine it is just not in the correct order for how the circuit is operating.

Pete.
 
You are mixing up the various lots of code and using the incorrect pin labelled code to modifie.
It is this one you should be using. TRY IT AGAIN!!!

Code:
'THIS VERSION 0005 BY SABORN

symbol switch_1 = pin4
symbol C_311 =    pin3
symbol motor =    2
symbol Y =        b1
 
main:
 
	if C_311 = 0 AND switch_1 = 0 then Delay 
 
 
	if C_311 = 1 OR switch_1 = 1 then 
	low 2  ; gas OR switch OFF, Motor OFF - if the flame is on in the middle 
	endif 
 
	goto main
 
Delay:
	for Y = 0 to 11
	wait 1
	if C_311 = 0 AND switch_1 = 0 then
	next Y
	endif
 
 
	if C_311 = 0 AND switch_1 = 0 then 
	gosub Gas_on
	endif
 
	goto main 
 
 
Gas_on:
 
	high 2  ;gas and switch ON, wait 12s and Motor ON
	return

Can you tell me in English how this system is meant to operate, dont worry about pin numbers just the human operation, as you would for telling me before you had built the circuit.
I am still somewhat confused over how all this operates and trying to write code with guessing what i think is correct.

The code works fine it is just not in the correct order for how the circuit is operating.

Pete.

Hmm okay that code seems to work.

The way the whole thing is supposed to work is as follows:

When we turn the gas nob a switch is turned on and pin3 of the 08M is High.

If there is a flame, then the thermistor gets hot and the output of the 311 goes High the 08M output is now Low and the motor is OFF.
If there is NO flame then the thermistor stays cold and the output of the 311 is Low, the 08M output is now Low and the motor is ON.

As the motor turns the nob around the switch turns OFF and the 08M pin3 goes LOW, causing the motor to turn OFF again.

Hope this is clear?

Now my code needs to reflect the fact that the output of the 08M is ONLY high when pin3 of the chip is High (the switch is ON) and pin4 is Low (there is NO flame).

Now the 12s wait is important because I want to make sure that the thermistor gets enough time to heat up as well as give people using the cooker enough time to use the spark thing in the cooker (dont know what its called) to turn on the flame.

We can sum up the way the 08M is supposed to work with the following code:

Code:
main:
if input4 = 1 AND input3=0 then
pause 12000
high 2
else
low 2
endif
goto main
 
Last edited:
The 08m2 will work fine, if you have the latest version of "Programming Editor" 5.4.0 it will automatically convert code written for a 08m chip into compatable code for the 08m2 chip during a download to the chip.

NOW you see why i told you to add some pins to allow programming of the chip in circuit, it makes life much easier.
I often use a 3 header pins in the same style as the pins you have used for the switch to plug in on, it costs very little and takes almost no space on the board.
Once you make a addaptor cable from your serial cable to the 3 header pin socket you have it for ever more.

The other avantage with this is you can run "Debug" in your program and see all the values from the picaxe on screen while it is operating in circuit.

I will read through your previous post again and comment in a little while.

Pete.
 
The way the whole thing is supposed to work is as follows:

When we turn the gas nob a switch is turned on and pin3 of the 08M is High.

If there is a flame, then the thermistor gets hot and the output of the 311 goes High the 08M output is now Low and the motor is OFF.
If there is NO flame then the thermistor stays cold and the output of the 311 is Low, the 08M output is now Low and the motor is ON.

As the motor turns the nob around the switch turns OFF and the 08M pin3 goes LOW, causing the motor to turn OFF again.

Hope this is clear?

Now my code needs to reflect the fact that the output of the 08M is ONLY high when pin3 of the chip is High (the switch is ON) and pin4 is Low (there is NO flame).

One of us is not correct here and i think it is you, as for starters the switch is connected to INPUT PIN4 and the 311 is connected to INPUT PIN3 not as you have listed above.

Are you sure like 100% sure the 311 output is LOW with no flame, and HIGH after 12 seconds with a flame present, as i had thought it was the other way around.
I dont know if your thermister is a NTC or a PTC thermister so i am unable to work it out from the circuit.

Then this................

If there is NO flame then the thermistor stays cold and the output of the 311 is Low, the 08M output is now Low and the motor is ON.

If the output of the 08m is LOW then the motor will be OFF, it needs a high on the output to turn the fet on which will turn the motor on.

From what you have told me for the operation and with correcting the input pins for the right function then this code should be correct.

I have also changed the code to make it written for the picaxe 08m2 chip.

Pete.

Code:
'THIS VERSION 0006 BY SABORN

#picaxe 08m2
 
symbol switch_1 = pinC.4
symbol C_311 =    pinC.3
symbol motor =    C.2
symbol Y =        b1
 
main:
 
	if C_311 = 0 AND switch_1 = 1 then Delay 
 
 
	if C_311 = 1 OR switch_1 = 0 then 
	low motor  ; gas OR switch OFF, Motor OFF - if the flame is on in the middle 
	endif 
 
	goto main
 
Delay:
	for Y = 0 to 11
	wait 1
	if C_311 = 0 AND switch_1 = 1 then
	next Y
	endif
 
 
	if C_311 = 0 AND switch_1 = 1 then 
	gosub Gas_on
	endif
 
	goto main 
 
 
Gas_on:
 
	high motor  ;gas and switch ON, wait 12s and Motor ON
	return
 
Heres a thought ........ solder a small wire on the bottom of the board from the broken pin 4 across to INPUT1 which is physical IC pin #6 and then we change the code to suit INPUT1 instead of the broken pin4.
This way you can still use the 08m chip.

In picaxe we speak in pin numbers as per the data sheet and the picaxe I/O numbering and NOT the physical IC pin numbers, as it just gets very confusing otherwise as might be the case above in your earlier post.

I will change the code back to 08M picaxe and move INPUT4 to INPUT1 but should this not be the correct pin4 you broke then the code will need further changes.

Pete.

Code:
'THIS VERSION 0007 BY SABORN
' pin4 moved to pin1
 
#picaxe 08m
 
symbol switch_1 = pin1
symbol C_311 =    pin3
symbol motor =    2
symbol Y =        b1
 
main:
 
	if C_311 = 0 AND switch_1 = 1 then Delay 
 
 
	if C_311 = 1 OR switch_1 = 0 then 
	low motor  ; gas OR switch OFF, Motor OFF - if the flame is on in the middle 
	endif 
 
	goto main
 
Delay:
	for Y = 0 to 11
	wait 1
	if C_311 = 0 AND switch_1 = 1 then
	next Y
	endif
 
 
	if C_311 = 0 AND switch_1 = 1 then 
	gosub Gas_on
	endif
 
	goto main 
 
 
Gas_on:
 
	high motor  ;gas and switch ON, wait 12s and Motor ON
	return
 
One of us is not correct here and i think it is you, as for starters the switch is connected to INPUT PIN4 and the 311 is connected to INPUT PIN3 not as you have listed above.

Are you sure like 100% sure the 311 output is LOW with no flame, and HIGH after 12 seconds with a flame present, as i had thought it was the other way around.
I dont know if your thermister is a NTC or a PTC thermister so i am unable to work it out from the circuit.

Then this................



If the output of the 08m is LOW then the motor will be OFF, it needs a high on the output to turn the fet on which will turn the motor on.

From what you have told me for the operation and with correcting the input pins for the right function then this code should be correct.

I have also changed the code to make it written for the picaxe 08m2 chip.

Pete.

Code:
'THIS VERSION 0006 BY SABORN

#picaxe 08m2
 
symbol switch_1 = pinC.4
symbol C_311 =    pinC.3
symbol motor =    C.2
symbol Y =        b1
 
main:
 
	if C_311 = 0 AND switch_1 = 1 then Delay 
 
 
	if C_311 = 1 OR switch_1 = 0 then 
	low motor  ; gas OR switch OFF, Motor OFF - if the flame is on in the middle 
	endif 
 
	goto main
 
Delay:
	for Y = 0 to 11
	wait 1
	if C_311 = 0 AND switch_1 = 1 then
	next Y
	endif
 
 
	if C_311 = 0 AND switch_1 = 1 then 
	gosub Gas_on
	endif
 
	goto main 
 
 
Gas_on:
 
	high motor  ;gas and switch ON, wait 12s and Motor ON
	return


Okay okay, let's see
One of us is not correct here and i think it is you, as for starters the switch is connected to INPUT PIN4 and the 311 is connected to INPUT PIN3 not as you have listed above.

The switch is in pin3 of the chip, but in the editor pin3 is called "input 4"

pin1 = Input1 = V+, pin2= Input2 = RXD and then it shows the pin3=Input4 also it shows pin4 = Input3

If there is NO flame then the thermistor stays cold and the output of the 311 is Low, the 08M output is now Low and the motor is ON.

Ah your correct,

The thermistor's resistance decreases with temperature so its an NTC thermistor. When its hot, the thermistors resistance decreases until its around 5k (it was initially10k) which means that most of the voltage will be across the positive terminal causing the output of the 311 to go High...your right I was being stupid, we should program it so that when the 311's output is High AND the switch is ON the motor's ON.
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    27.9 KB · Views: 145
Last edited:
Work from the diagram in the manual (in the PE help section under manual 1)

There is this diagram and when we talk code and pin numbers we use the numbers on the outside of the drawing and NOT the numbers inside the square.

Pete.
 

Attachments

  • 08m pinouts.JPG
    08m pinouts.JPG
    28 KB · Views: 158
Work from the diagram in the manual (in the PE help section under manual 1)

There is this diagram and when we talk code and pin numbers we use the numbers on the outside of the drawing and NOT the numbers inside the square.

Pete.

Yeah I think we both agree! okay so what needs to be done it program the chip so when In4 and In3 are High , wait 12s and Out2 is High. else Out2 is Low.
 
Last edited:
By memory the LM-311 has an open collector output so with the thermister cold i would expect the LM-311 output to be off and pulled high via the pullup resistor and when the thermister gets hot the LM-311 output would go low as the transistor inside the LM-311 would be switched on.

This is opersite to what you have just stated so i think you need to test the output of the LM-311 with a multimeter to see if the output is high or low when the thermister is cold.
Measure between ground and the LM-311 output and see what voltage you read.
We need to know for sure how it is operating.

IE:- thermister cold = 311 output high
thermister hot = 311 output low

Pete.

Ps i will check back tomorrow...................
 
Last edited:
NOPE wait, when there is gas then the 311 will be LOW (no flame, thus no decrease in thermistor resistance and thus 311 Output is LOW). So motor ON when 311 Output is LOW meaning

In4 = 1 and In3 = 0.
 
Status
Not open for further replies.

Latest threads

Back
Top