Help with Motor Position-er please

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Help with Motor Position-er please

Post by acestu »

Hi,

I am trying to make a positioning system for a linear actuator motor on a lawn mower, the broken one has 9 positions on it with 9 different positions of the motor, thinking about it I suppose what I have to do is divide the pot feedback into 9 and give each variable its number and when the particular button is pressed the microcontroller has to work out which way the motor should go to get to the position number quickest, the motor up and motor down outputs would drive a relay connected to the motor. I would love to hear your feedback on this and any pointers are welcome, I am enclosing the start of a chart...

EDIT: I don't need to control the speed of the motor just direction so I would probably be using a H Bridge...

Thanks in advance
Acestu
Cutting_Deck.fcf
(23 KiB) Downloaded 310 times
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Help with Motor Position-er please

Post by acestu »

Hi,

I am trying to work out which way to go with this, I have done some more at the chart but could do with somebody telling me if I am
going in the right direction really, I will post the newer chart....


Thanks in advance
Acestu

EDIT: Thinking about it I would want the deck height to remain the same when the power is cut and then re applied, how would I implement this ?, would it involve using the eeprom component ? ie once you have adjusted the height it is written to the eeprom...
Cutting_Deck_MK2.fcf
(30.99 KiB) Downloaded 332 times
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times

Re: Help with Motor Position-er please

Post by dazz »

Hi Stu
have you got a link to the linear actuator and the mower as it might give a better idea of what needs done

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Help with Motor Position-er please

Post by acestu »

Hi Dazz,

the motor is on the lawn mower, I will post a diagram but I don't think it will tell you much, I think I will have to take some readings off the motor on the lawn mower...What info do I need, Motor FLC & pot value ?

thanks
Stuart
actuator-motor_&pot.jpg
actuator-motor_&pot.jpg (110.83 KiB) Viewed 13094 times
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times

Re: Help with Motor Position-er please

Post by dazz »

Hi Stu
Motor nah i wanted the make and model of the mower :lol: .
do you also know the make and model of the actuator

regards
Dazzz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Help with Motor Position-er please

Post by acestu »

Hi Dazz

the mower is an old Countax A20-50 ride on mower, I will pull the top off it tomorrow and see if there is anything on the motor, I think that would be the easiest way as it doesn't give anything away on the parts diagram.

thanks
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Help with Motor Position-er please

Post by acestu »

Hi,

I am just experimenting with the eeprom module and how to make a scroll button, I don't know how to make the scroll button just scroll up to 9 though.....

here is my chart.
Cutting_Deck_MK3.fcf
(10.5 KiB) Downloaded 312 times
Thanks
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Help with Motor Position-er please

Post by acestu »

Hi,

I am not sure if this is the right way to do it but it seems to work....

Thanks Stuart
Cutting_Deck_MK4.fcf
(11 KiB) Downloaded 316 times
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Help with Motor Position-er please

Post by medelec35 »

Not taking over since your in good hands with Dazz. :)

Attached is a flowchart that goes from 1 to 9 then after 9 goes back to 1.
Is that what you're after?

I will leave Daz to help you with the rest as Daz likes a challenge :P

Martin
Attachments
Cutting_Deck_MK4.fcf
(11 KiB) Downloaded 313 times
Martin

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Help with Motor Position-er please

Post by acestu »

Hi Martin,

Always nice to hear from you, and as you said before now the more input the better, yes this bit of a project will hopefully teach me a bit more about Flowcode, I could buy one of these units to replace the duff one but if I do that I will not learn anything, I have just broken it down into small parts and I have just figured out how to make the button just scroll to 9 then back to zero, I take it that the Eeprom is a non volatile memory that will store my setting for the next time it is turned on, this is interesting also, right I will have a look at your code and mark mine lol :D

Thanks
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Help with Motor Position-er please

Post by acestu »

Hi Martin,

Wow I had actually worked that out, I just had ten positions instead of nine, so I set the variable initial to 1 instead of zero and changed the calculation to 1 instead of zero, because I am writing to Eeprom I take it that the chip will start next time with whatever was left in there ?...

The more you do with Flowcode the more falls into place, and I am really enjoying it....

thanks
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Help with Motor Position-er please

Post by medelec35 »

Your welcome Stuart.
acestu wrote: I take it that the Eeprom is a non volatile memory that will store my setting for the next time it is turned on
Yes, The EEPROM is a not volatile memory storage.

I have not fully corrected your Flowchart as it aids learning.
acestu wrote: because I am writing to Eeprom I take it that the chip will start next time with whatever was left in there ?...
What you will need to do is only read EEPROM and use it to retrieve settings only if Value of EEPROM is less than 10.
If you place the read EEPROM at the start before Main loop,when power is first applied to chip you can check to see if value is less than 10, if it is then Height = value within EEPROM.
Also most important!:
EEPROM have only a limited amount of write and read cycles (You can check how many on the target devices datasheet.
Therefore you should only write to EEPROM after Height variable has changed.

So do not leave EEPROM where is is to keep constantly updating in the tight loop its currently in.
acestu wrote:Wow I had actually worked that out
Nice one!
Glad you're enjoying it.
I love it still after all this time.

Martin
Martin

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Help with Motor Position-er please

Post by acestu »

Hi Martin,

I have read a bit about the Eeprom and it seems that it wears out if used too much, I don't quite get what you say here:

"What you will need to do is only read EEPROM and use it to retrieve settings only if Value of EEPROM is less than 10."

Surely the EEprom is always going to be less than ten if that is where I am storing the current cutt height?

Is this the only way to do this or could it be done some other way without using the EEprom?

Thanks
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Help with Motor Position-er please

Post by medelec35 »

acestu wrote:"What you will need to do is only read EEPROM and use it to retrieve settings only if Value of EEPROM is less than 10."

Surely the EEprom is always going to be less than ten if that is where I am storing the current cutt height?
All EEPROM memory locations default to FF (255) When the microcontroller is first reprogrammed
So if your program is ran for the very first time after programing, then EEPROM = 255

If you're using EEPROM to restore servo to its original position hence read EEPROM at the start then yo will be retreaving 255 instead of say 5 for an example.
Thats why I suggested read EEPROM and use its contents if less than 10.
acestu wrote:Is this the only way to do this or could it be done some other way without using the EEprom?
EEPROM was designed for this application. :)
I use eeprom in a few of my applications, I believe it's the best way for you.
Just don't leave it where it is.
Martin

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Help with Motor Position-er please

Post by acestu »

Hi Martin,

Right I see what you mean now it would be wrong just that first time it was used, I will try and get the motor off tonight so that I can have a mess on the bench with it, it's really awkward without the hardware, I haven't forgotten the fan speed controller that you told me about just trying to get another fan so that I can mess on the bench with it the same...


Thanks
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Help with Motor Position-er please

Post by acestu »

Hi,

I have found a PDF manual for the motor, also I have taken it off now and it has 2 wires for motor ie Red & Black and 3 wires for the pot ie Red White & Blue as per the PDF...

EDIT: Looking at the the PDF it says that the FLC is 13 amps so not sure how I am going to drive such a high power ?

Thanks
Stuart
Actuator.pdf
(112.15 KiB) Downloaded 243 times
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times

Re: Help with Motor Position-er please

Post by dazz »

Hi Stu
There are a few options, what i have done in the past with stuff like this is connect a pot with long wires to the actuator, adj pot to the required positions(measure pot resistance at each position) then use a rotary switch with a resistor for each position, simple cheap and will last for years.

If i was doing a Uc control i would not use the eeprom what i would do is before the main loop add an on off switch(you don't want the deck moving before the engine is running ,i would add a small relay to the charge light from the alternator so that the relay only toggles when the engine is running a safety on off switch also add a delay) . At this point i would also retract the deck to its high position as ive repaired many a dented deck due to people driving off the cutting area with the deck lowered then catching a flagstone or a brick etc.
Martins chart will give you a 9 position button
i would maybe look at it this way
if engine running no do nothing
if engine running yes wait 30 seconds(allow battery to get a bit of juice and engine to come off choke)/ return deck to highest point
goto martins chart /select height /10 second delay(this will allow time to select desired height with out the actuator moving continually /move actuator to selected position
scan buttons for emergency button/ if pressed return to high position( this does what it says on the tin also press when finished mowing as it allows you to drive off knowing you aren't going to catch the deck.

hope the above gives you some ideas but i feel you at least need the safety bits i've outlined are needed. to take a relay from the alternator look up simple relay split charge on google, don't make a permanent connection to your alternator till you know it works as some alternators don't like their charge light wires fiddled with.
Also when you're using a pot to get the positions you need also connect the pot to the pic so you can read the analogue input values, that will give you some numbers to play with

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Help with Motor Position-er please

Post by acestu »

Hi Dazzz

I will have a better look at this when I get home, I have just had a play with the actuator and measured some resistances:

Actuator Fully Out 6.96K

Actuator Fully In 9.69k


Cheers
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Help with Motor Position-er please

Post by acestu »

Hi,

I made an ADC test device and wired it up to the motor pot on the bench, I then applied 12 volts measuring the travel length and came up with these numbers:

All the way in at 11, 20, 29, 38, 47, 56, 65, 74, 80 All the way out

It is a bit difficult with only having whole numbers

My bench supply also said that the FLC was no where near 13 amps and it was more like 3.5 but there was no load, I am still looking for ideas on how to drive this motor , do you think a transistor driven reversing relay would do the trick ?

EDIT: I don't think all of the safety measures are needed Dazzz because there is a PTO fitted which has to be engaged before the blades on the cutting deck go round.

thanks
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times

Re: Help with Motor Position-er please

Post by dazz »

Hi Stu
the two safety measures i would implement are the initial delay before the deck can move to allow the engine to steady itself and the battery to start chaging, also i personally would have the deck return to the high position at the start of the day and at the end for the only reason is more deck get damaged being left down and bashing into things :lol:

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Help with Motor Position-er please

Post by acestu »

Hi Dazzz,

Yes your right I will put those in the chart if I can, I have just connected a little H-Bridge that I had just to see if I could control it like that and it worked fine, only thing is it is only 2 amp and it was red hot, so I suppose if I get a 10 amp one it should do the trick, I have had the motor on the bench and I am happy with the ADC numbers that I got so I will have another look at the chart now and see what I can come up with...

Edit: If anybody knows where I can buy a cheap single channel 10 or 20 amp H-Bridge then please let me know :wink:

Thanks
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times

Re: Help with Motor Position-er please

Post by dazz »

Hi stu
something to ponder a timed relay fed from the alternator feeding the main motor supply would take care of the first safety condition
the second one is simply another switch that returns the deck to high, before the main loop add a delay equal to the timed relay, then return the deck to its high position, then move onto martins switch cycle.
i suspect you could position the actuator from where the pot connects

Regards
dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Help with Motor Position-er please

Post by acestu »

Hi,

I have just bought one of these:

http://www.ebay.co.uk/itm/121058925165? ... 1439.l2649

Hopefully it will work ok, It is 240 watts so it should be powerful enough, I am just wondering though if I need PWM to operate it ?

thanks
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times

Re: Help with Motor Position-er please

Post by dazz »

hi stu
attached is a datasheet for a timed on relay
i'll have a think tomorrow as my brains slowing down only had 2hrs sleep in the last 48hrs :lol:

regards
Dazz
Attachments
c.pdf
(314.28 KiB) Downloaded 212 times
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times

Re: Help with Motor Position-er please

Post by acestu »

Hi Dazzz,

Yes interfacing to the alternator is tricky because the connection would have to be on the internal side of the diodes otherwise it would be live all the time as it is connected to the pos of the battery, and a connection to the field coil could upset things like you said earlier...its a bit tricky really sensing when the engine is running..

cheers
Stuart
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

Post Reply