Switching issues

PhilHornby

Senior Member
I think the tube was therefore pushing the stall-reset permanently would only cause an issue if the unit went into stall.
The Picaxe won't boot with that switch pressed - it boots about two seconds after it is released (or immediately if it was not pressed at power-on).
This info. may help with your investigations...
 

Rampz

Well-known member
The Picaxe won't boot with that switch pressed - it boots about two seconds after it is released (or immediately if it was not pressed at power-on).
This info. may help with your investigations...
Yes Phil that's right on this occasion he fitted the lid that pushed the button with the picaxe already running, so he didn't notice anything wrong, had he fitted the lid with power off then your right it would never have booted but he would see the heart beat led but it would start flashing instantly rather than after a delay.
 

hippy

Technical Support
Staff member
Ok he asked me to reduce the drive pulse to 200ms which i did, now this drive is on the chimes side of the clock, when its triggered it can drive continiously for between 1 and 12 chimes, i think what was happening manly for the higher hours that the 200ms wasn't long enough for the tilt switch to open so the picaxe would see the motor running continously
This confuses me. If you are giving a 200ms drive pulse to the motor then how can the motor still be running after 200ms ?

If you means the motor runs for a minimum of 200ms that's fair enough. But if it runs for 200ms and the tilt switch hasn't by then activated it runs for some more. It will only timeout and indicate a stall if it's run for 6 seconds and the tilt switch hasn't de-activated.

My question would be why, after 6 seconds of winding, that tilt switch hasn't de-activated ?

It can only be that the motor wasn't doing any winding or the tilt switch isn't reflecting the state of being wound.

Plus your code as posted doesn't actually do as described here. It turns the motor on until tilt is no longer activated or a stall is detected. If there isn't a stall it then runs for some extra time during which, if the tilt is activated again, it restarts winding from the beginning.

It seems to me that's prone to tilt-switch bounce issues, a potential determination that it has been wound when it hasn't, or that it's not been wound when it has. It's hard to say because the mechanism implemented is too convoluted for me to get my head around.

IMO the fundamental issue comes back to not having reliable 'is wound' detection, trying to use the inverse of 'needs winding' to determine when it has been.

It's like having a very swingy bar door and a magnetic switch indicating it is in its static closed state. You can use that to determine when someone has walked in but you can't determine when they have been kicked out unless it has stopped swinging first. The instantaneous state of the magnetic switch doesn't provide that information.
 
Last edited:

Jack Burns

New Member
Cross posted with Hippy.

But what is the effect on the drive if its sat in its stall position with tilt switch showing closed and the picaxe restarts. So picaxe restarts with tilt switch closed, it would show normal operation i think with heart beat, stall-reset wouldn't work because it wouldn't think its in a stall, motor won't drive either because it will never see the tilt go closed because it was already closed??
If the picaxe restarts then the picaxe will just run the code as normal, so if the tilt switch is closed then the motor will be driven. StallReset would still work because that button only gets checked towards the end of the MotorStalled subroutine after the OLED has been updated.


On the drives the recall button is covered its not intended to be used by the user
If the clock bloke removed the lid to connect the screen, then there's a good chance he pressed the button. This could be for one of a few reasons..
a) Curiosity - wondering what that hidden button does.
b) Seen you press it and thinks it's a magic button which fixes things
c) Genuine mistake as the lid is off - simply got the 2 buttons mixed up and meant to press the StallReset button

so having pressed the recall button, he now has to wait over 10 minutes for the 253 stalls to be flashed out, before the picaxe could attempt to restart the motor.

clock bloke needs to be careful around stall-reset button.
This was also part of my reasoning for needing the button to be held down for around 2 seconds, as it make it more difficult for an accidental reset.

Second test,
Got drive to point where tilt switch closed and it went into stall, I had stall-reset already permanently pressed, stall constantly reset, counter incrementing constantly
Correct. However the motor will still be run for up to 6 seconds provided the power is kept on. If the power is cycled with the StallReset still on, then the picaxe will just keep looking for a new download.

So this still begs the question of how did you get a stall count of 253 because the motor should have still moved. I keep coming back to whether the mosfet is occasionally failing to turn on. Have you used the same mosfet in all versions, because this stall problem was also present when you used a 555?

Suggest you put an LED with series resistor on C.4 and then compare what this LED and the motor LED are doing when problems occurs, or you use the StallReset button and it fails to work.

he asked me to reduce the drive pulse to 200ms which i did, now this drive is on the chimes side of the clock, when its triggered it can drive continiously for between 1 and 12 chimes, i think what was happening manly for the higher hours that the 200ms wasn't long enough for the tilt switch to open
It's probably the other way around, so at the higher hours 6 seconds is probably too short for the autodrive to keep up with the mechanism unwinding.

With the drive pulse set at 200ms, the drive will still run continually for up to 6 seconds if the tit switch calls for it.
However, when the tilt switch is on the verge of opening, then 200ms may be too short for the motor to physically move but may be enough to give the motor a jolt which re-opens the tilt switch. This would NOT register a stall but may keep happeneing until the mechanism has unwound slightly allowing the autodrive to receive a longer drive pulse.

Perhaps you should run a test program that sends a 200ms drive pulse every couple of seconds to see if motor does actually move. Either test it on the clock, or use a seperate test rig. If using a test rig, then make sure the motor has a load similar to what the spring provides so that it's a fair comparison.
 

Rampz

Well-known member
This confuses me. If you are giving a 200ms drive pulse to the motor then how can the motor still be running after 200ms ?

If you means the motor runs for a minimum of 200ms that's fair enough. But if it runs for 200ms and the tilt switch hasn't by then activated it runs for some more. It will only timeout and indicate a stall if it's run for 6 seconds and the tilt switch hasn't de-activated.

My question would be why, after 6 seconds of winding, that tilt switch hasn't de-activated ?
Hippy On the chimes side of the clock and lets assume its going to chime 12 o'clock, during the chiming the barrel in the clock that the motor is attached to will rotate all the time and this could be for 30 seconds or more, when the drive pulse is too short and therefore against a constantly rotating barrel the pulse isn't enough to open the tilt switch, the code at this time carries on driving the motor but because the tilt switch remains closed it doesn't get to see an open that would reset the 6 second stall timer, if it doesn't get to see an open for 6 seconds it will stall, normally the motor does run faster than the barrell un rolls, if its a longer pulse the the motor drives further the first time and far enough to open the tilt switch, maybe a second later it goes again and so on, but stays well ahead of the requiriment, if it lags behind and ends up in the constantly closed tilt switch area then it can get into a stall situation.

Plus your code as posted doesn't actually do as described here. It turns the motor on until tilt is no longer activated or a stall is detected. If there isn't a stall it then runs for some extra time during which, if the tilt is activated again, it restarts winding from the beginning.
Yep it turns the motor on for all tilt activations plus 400ms after the last tilt switch open, if tilt pulses are less than 400ms the motor stays running but the stall timer keeps resetting, so as long as thetilt keeps opening the motor can run for as long as needed, if the tilt becomes permantly on then the stall happens at 6 seconds
 
Last edited:

Rampz

Well-known member
So this still begs the question of how did you get a stall count of 253 because the motor should have still moved. I keep coming back to whether the mosfet is occasionally failing to turn on. Have you used the same mosfet in all versions, because this stall problem was also present when you used a 555?
Jack i think because this was on the chimes drive, the clock drive was fine, so the clock kept running but everytime the chimes was needed we got into a stall and reset position with the motor running for 6 seconds and stopping and resetting and running again until the chiming had finished, each hour this would repeat at a growing length because the hour was getting later meaning longer chiming, but at 253 counts the picaxe likely restarted and then stayed in the constantly trying download position

It's probably the other way around, so at the higher hours 6 seconds is probably too short for the autodrive to keep up with the mechanism unwinding.
I don't think its an issue, aslong as the pulse is always enough at 400ms after any tilt closing for the motor to always fully open the tilt switch then it can carry on being driven and not get the stall situation, on this drive i was asked to make the pulse 200ms which i don't think is long enough to more the motor far enough to keep the tilt fully open agains an undoing chime barrel

With the drive pulse set at 200ms, the drive will still run continually for up to 6 seconds if the tit switch calls for it.
yes true and stop if the tilt switch is closed for that 6 seconds, if the tilt switch opens and closes during the motor running then it will run till 400ms after the tilt's last open
 
Last edited:

Rampz

Well-known member
Perhaps you should run a test program that sends a 200ms drive pulse every couple of seconds to see if motor does actually move. Either test it on the clock, or use a seperate test rig. If using a test rig, then make sure the motor has a load similar to what the spring provides so that it's a fair comparison.
The test clock that the clock bloke uses has the biggest motor he uses along with more weight hung off it than is normally used and its still been left set at 200ms.

I could alter the test clock i'm using and alter the drive pulse to a smaller number but its on the clock side i really need a drive on my chimes side to be able to test that out
 

Rampz

Well-known member
If the clock bloke removed the lid to connect the screen, then there's a good chance he pressed the button. This could be for one of a few reasons..
a) Curiosity - wondering what that hidden button does.
b) Seen you press it and thinks it's a magic button which fixes things
c) Genuine mistake as the lid is off - simply got the 2 buttons mixed up and meant to press the StallReset button

so having pressed the recall button, he now has to wait over 10 minutes for the 253 stalls to be flashed out, before the picaxe could attempt to restart the motor.
He does know what the 2 buttons do and which is which.

He attached the screen to read the faults, by removing the lid i think he cleared the stall-reset button being constantly pushed by the tube on the back of the lid, so cleared one problem, since the motor wasn't moving at all, i think the picaxe had restarted after its 253 stall, so was sat in a download position which cleared when the lid was removed, he plugged the screen in and pressed the stall-reset button which didn't do anything since it wasn't in a stall it was booting up from having the screen connected, most likely it caused it to reboot again if done within 20 seconds of adding the screen, he must have waited for the screen to show the errors which he sent me a picture of, the screen didn't show the voltage so was at the start of the code, at which point i think he pressed the recall button and started the 10.3 minutes of led flashing, he did say it took a while to clear, after that he forced the motor unit to a position where the tilt switch was open and its worked just fine since
 

Rampz

Well-known member
IMO the fundamental issue comes back to not having reliable 'is wound' detection, trying to use the inverse of 'needs winding' to determine when it has been.

It's like having a very swingy bar door and a magnetic switch indicating it is in its static closed state. You can use that to determine when someone has walked in but you can't determine when they have been kicked out unless it has stopped swinging first. The instantaneous state of the magnetic switch doesn't provide that information.
Hippy yep it is a difficult one to know how to work it, for the clock drive giving a drive pulse long enough for the motor to move and open the switch is enough, so clock is constantly slowly unwinding against a motor that has eith a weight or spring attached, after sometime the motor moves to a position where the tilt switch closes and the motor adds some more tension for the length of the drive pulse and the tilt opens.

The bigger issue is the chimes side, it works in just the same way but say at 1 o'clock it needs to drive for say 1 pulse is enough, at 2 o'clock its a longer time needed because the clock needs to chime twice and so on and so on, all we want is when the tilt closes it drives the motor and at the last pulse of the hour it stops in a position where its open for sure, so it works well that during a motor on session the tilt keeps opening and closing, this keeps the stall timer below the 6 seconds, if for some reason the motor becomes stuck then being sat in a motor stall for 6 seconds we want it to turn off untill the problem is sorted, its likely that the tilt would be closed at this time and becuase the motor is being driven but isn't moving then it would reach its 6 seconds and stop
 

Rampz

Well-known member
This was also part of my reasoning for needing the button to be held down for around 2 seconds, as it make it more difficult for an accidental reset.
Yes i agree with you but the context for the part you copied was when putting the lid onto the box i think the small guide tube the clock block had attached to the rear of the lid was now pushing on the stall-reset button, if with the 2 second coding if the button is pressed all the time does it still get the effect of working every 2 seconds? So i was meaning he as to be careful around the button with regards to assembly
 

hippy

Technical Support
Staff member
against a constantly rotating barrel the pulse isn't enough to open the tilt switch, the code at this time carries on driving the motor but because the tilt switch remains closed it doesn't get to see an open that would reset the 6 second stall timer, if it doesn't get to see an open for 6 seconds it will stall, normally the motor does run faster than the barrell un rolls, if its a longer pulse the the motor drives further the first time and far enough to open the tilt switch, maybe a second later it goes again and so on, but stays well ahead of the requiriment, if it lags behind and ends up in the constantly closed tilt switch area then it can get into a stall situation.
So, while chiming, a motor run time of 6 seconds isn't enough to rewind and deactivate the tilt-switch, but is enough to be treated as a stall condition, which stops the motor, allows it to fully unwind, and that's it until someone manually resets it.

Seems to me the stall time is simply too short for how long the motor needs to run for and the fix would be a longer stall time.
 

Rampz

Well-known member
So, while chiming, a motor run time of 6 seconds isn't enough to rewind and deactivate the tilt-switch, but is enough to be treated as a stall condition, which stops the motor, allows it to fully unwind, and that's it until someone manually resets it.
Hippy it doesn't work like that during the chiming the motor manages to stay ahead of demand so the motor turns on and off during the chiming because the tilt switch turns on and off during chiming, and at 400ms pulses it works fine, at 200ms pulses its possible that the motor doesn't always move far enough to turn the tilt switch off and if that happens for long enough it can get into a stall situation, so i need to be careful with the length's of the pulses, just on this occasion it all went wrong it seems the stall-reset button was held in permantly which isn't the idea and it all went crazy
Seems to me the stall time is simply too short for how long the motor needs to run for and the fix would be a longer stall time.
Like i say the run is made up of several short drives none of which are ever 6 seconds long, if i go the other way and increase the stall time to say 60 seconds and the motor does jamm then it could just burn out, so its getting a happy middle ground between pulse length and stall time
 

papaof2

Senior Member
How much additional hardware could be added? The ACS712 series of current sensors (5, 20 and 30 amp versions) can be read by a PICAXE (needs one pin) to determine the actual current and you could have a true "stall" sensor. If the motor is supposed to be turning, check its current every X seconds or if you're in a loop doing other things, just add the check to the loop. If the current is normal, it's working as designed. If there's no current, the motor didn't start or has finished. If there's excessive current, the motor is stalled.

Yes, another part and more wiring and a little more code (reading an ADC and making a multi-way decision) but you would KNOW whether the motor is running normally. If the motor is at stall current, exit to a "stop the motor and flash an LED" place. That chip with a few more pins and a bit more memory just might be worth it ;-)

The circuit boards with screw terminals that simply go inline with a power lead to the motor are around $10-$12US on eBay (delivered) - there are vendors asking under $5US (delivered) but their shipping time may one to three months :-(

ACS712 datasheet: https://www.sparkfun.com/datasheets/BreakoutBoards/0712.pdf
 

Rampz

Well-known member
How much additional hardware could be added? The ACS712 series of current sensors (5, 20 and 30 amp versions) can be read by a PICAXE (needs one pin) to determine the actual current and you could have a true "stall" sensor. If the motor is supposed to be turning, check its current every X seconds or if you're in a loop doing other things, just add the check to the loop. If the current is normal, it's working as designed. If there's no current, the motor didn't start or has finished. If there's excessive current, the motor is stalled.

Yes, another part and more wiring and a little more code (reading an ADC and making a multi-way decision) but you would KNOW whether the motor is running normally. If the motor is at stall current, exit to a "stop the motor and flash an LED" place. That chip with a few more pins and a bit more memory just might be worth it ;-)

The circuit boards with screw terminals that simply go inline with a power lead to the motor are around $10-$12US on eBay (delivered) - there are vendors asking under $5US (delivered) but their shipping time may one to three months :-(

ACS712 datasheet: https://www.sparkfun.com/datasheets/BreakoutBoards/0712.pdf
Interesting you should talk about those boards Papaof2 i have got some of the 20A boards here to look at when i have spare time, i have had that thought but for a slightly different reason, these drives are made to be diy fit and he finds people putting stupid weights on them like 20kg etc or pulling the spring so tight its like its lifting 20kg, so a thought was to use them to get a read out of current draw from a setup point of view, we have used the current meters from ebay but the refresh rate is too slow to catch the current from a drive that can be on for just 400ms, so was looking to use them in the controller when i was looking at talking to the drives over RS232, it could then display the current draw for all drives.

In the current drives i am low on space, i could fit the chip directly if i could actually find them, can only seem to find the pcb mounted version as a test item, i would also need to go to a 14M2 which i have looked at, but the first 20x drives are built and based around the 08M2, i can alter etc.

Be good to look at code to read the sensor and would need a good refresh rate also, maybe sample 10 times a second when the motor runs and display the highest reading for 2 seconds or something and repeat
 

papaof2

Senior Member
The bare chips are available from the electronics houses (mouser.com, etc) and on eBay. I think it's an 8 pin SMD chip so very little space needed - just adequate connections to handle the motor's current.

The chip is sensitive to magnetic fields so there should be some minimum distance from the motor - maybe in the datasheet?
 

Rampz

Well-known member
If it "works fine" I am no longer sure what problem you are trying to solve.
Hippy it was just that in a live clock we found a huge stall reading and the clock had stopped and i was trying to piece together what went wrong, i was asked to make the pulse 200ms and maybe that and other factors could have caused, there may well be no fault at all, these drives over the last year when using the 555 timer setup which basically did the same would from time to time just stop and we never got to the bottom of it, hoping picaxe is the answer, since it will just keep following the code, so hoping all is good
 
Top