Can someone tell me where I have gone wrong

For MIAC users to discuss projects, applications, and any other issues related to the MIAC unit.

Moderators: Benj, Mods

Post Reply
markkkk
Posts: 21
Joined: Fri Jul 28, 2006 3:30 am
Location: Brisbane Australia
Contact:

Can someone tell me where I have gone wrong

Post by markkkk »

I am trying to get the Miac green and red buttons to operate a dc motor in forward and reverse using A and B like a H bridge. I cant get the red and green buttons to work on the simulator either. Obviously I am not reading the buttons correctly. Some guidance would be appreciated please
'
Attachments
Marks_Miac1.fcfx
(7.66 KiB) Downloaded 776 times

markkkk
Posts: 21
Joined: Fri Jul 28, 2006 3:30 am
Location: Brisbane Australia
Contact:

Re: Can someone tell me where I have gone wrong

Post by markkkk »

You will see this is a work in progress by the variable list. If I am having trouble with this imagine when I try to do the isr

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

Re: Can someone tell me where I have gone wrong

Post by medelec35 »

Hi Mark,
You just need to drag the Get keypad component within the main loop as its used to read which key is actively pressed:
Miac Keypad.png
(4.97 KiB) Downloaded 20401 times

Martin
Martin

markkkk
Posts: 21
Joined: Fri Jul 28, 2006 3:30 am
Location: Brisbane Australia
Contact:

Re: Can someone tell me where I have gone wrong

Post by markkkk »

Hi Martin

Thanks for that. It worked as I thought it should now. Beginner mistake of course as now I see it it makes sense totally. Now to add a few more things to it and see how it goes. Thanks for the fast response too


Mark

markkkk
Posts: 21
Joined: Fri Jul 28, 2006 3:30 am
Location: Brisbane Australia
Contact:

Re: Can someone tell me where I have gone wrong

Post by markkkk »

I found a example called motor5 which if you look at the JPG which is pretty much perfect although I wont be using the PWM for the motors but I do have a opto output from the actuators so I can measure the distance I am just using the ABCD ports as a H bridge which works well now. The interrupt for the opto is just what I was intending to do

The example is a flowcode5 one but I convert it to a V6 and it doesnt simulate it comes up with "array index out of bounds" and a unitialized variable

Here is the original file attached can anyone else please check that it will work as a V6 file. I dont want to use the pot for speed I just want to use a start button that will start a open sequence to a set distance and another button to start the close sequence there will also be limit switches on I1 and I2 just to make sure it will be all safe

Also attached is the current file that uses the red and green buttons on the Miac while you hold them down the motors move in the required directions but the lcd message drops in and out when going in either direction and I cant seem to be able to keep that up on the screen while holding the button down

AND flowcode keeps crashing after doing simulations usually after about 4 or 5 simulations
Attachments
MOTOR5.jpg
(97.32 KiB) Downloaded 12782 times

markkkk
Posts: 21
Joined: Fri Jul 28, 2006 3:30 am
Location: Brisbane Australia
Contact:

Re: Can someone tell me where I have gone wrong

Post by markkkk »

here is the original file
Attachments
MOTOR5.fcf
(10 KiB) Downloaded 1077 times

markkkk
Posts: 21
Joined: Fri Jul 28, 2006 3:30 am
Location: Brisbane Australia
Contact:

Re: Can someone tell me where I have gone wrong

Post by markkkk »

Here is my current working file but it just works the motor backward and forwards when holding the green or Red buttons
Attachments
Marks_Miac1_working.fcfx
(8.96 KiB) Downloaded 786 times

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

Re: Can someone tell me where I have gone wrong

Post by medelec35 »

Hi Mark,
No problem.
Flowchart is a bit rushed as have to pop out.
Hopefully works more as you intended.
The crashing is a known bug, and a short delay within the main loop sorts it out.
As It happens placed a delay anyway to prevent LCD being updated too quick on hardware.

Martin
Attachments
Marks_Miac1_working2.fcfx
(9.98 KiB) Downloaded 750 times
Martin

markkkk
Posts: 21
Joined: Fri Jul 28, 2006 3:30 am
Location: Brisbane Australia
Contact:

Re: Can someone tell me where I have gone wrong

Post by markkkk »

Thanks again Martin yes it now works as I intended Just another trick I have to learn. The issue with the Motor5 example have you looked at that at all. I need to use the ISR to read a opto for use with this but the example I can not get it to work at all. There must be something wrong with the example or it doesnt translate over into Flowcode 6

Now also looks like I will need to do a PWM with this as my mate wants 2 different speeds from the actuators. one will go at a set speed the other will start slower then after a certain distance (using the count from the opto) then the speed will ramp uo to a different set speed. All of this to open and close the big bonnet of a hotrod he is building. And I thought my hobbies were strange :)

Mark

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

Re: Can someone tell me where I have gone wrong

Post by medelec35 »

Hi Mark.
It should be easy to get flowcode V5 example to work in V6.
For Array index out of bounds error it's a known conversion issue.
What you do is where you see PrintASCII and it contains a string , you just replace it with PrintString.
For example PrintASCII "Analog input I1" you need to change to PrintString "Analog input I1"
The Uninitialized variable just means the variable is read before it's written.
If you find the variable in Project Explorer within View Menu
When cursor gets near the variable a drop down arrow will appear. click on it then choose Edit.
Just type a value in the Initial value window (0 will do) then OK.

Martin
Martin

markkkk
Posts: 21
Joined: Fri Jul 28, 2006 3:30 am
Location: Brisbane Australia
Contact:

Re: Can someone tell me where I have gone wrong

Post by markkkk »

Thanks again Martin

Yes that has cured the problem. I have loaded the program into my Miac but it doesnt work. The motor doesnt run and also the pwm output level does not change when you vary the pot. It is wired exactly as per the diagram above. It is like the pwm duty cycle is not reading. The only variable that came up as unitialized was the tacho_x and I just put a 0 in there but that is for the counter not the pwm. There is no motor on the simulator and no reference to it in the code either . So the example doesnt seem to work at all certainly when I load it and also on the simulator you can move the pot and nothoing happens on the PWM on the display it just remains at zero

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

Re: Can someone tell me where I have gone wrong

Post by medelec35 »

Hi Mark,
I have just looked at the motors example.
There is a bug so it would have never worked on flowcode V4, V5 or V6.
In the interrupt macro it shows

Code: Select all

If: isr_count = 512
Yet isr_count variable is assigned as a byte:
Motors Bug.png
(45.75 KiB) Downloaded 20266 times
So it will go up to a maximum value of 255 then after .

Code: Select all

isr_count = isr_count + 1
will roll-over to 0
To resolve this you will need to change the variable from a byte to an integer.
This is done by selecting variable in project explorer, then Edit.
After making that change PWM should work

Martin
Martin

markkkk
Posts: 21
Joined: Fri Jul 28, 2006 3:30 am
Location: Brisbane Australia
Contact:

Re: Can someone tell me where I have gone wrong

Post by markkkk »

Hi Martin

Thanks for the help on the interrupt. I have decided to go another way using the internal limits in the actuators to effect the stopping of the rams. I have tested this and it seems to work ok rather than trying to count the pulses as it makes life easier. I have got the sequencing right now and it all works just how I want it to except one issue. On the sim there are 4 pushbuttons. 2 are for the open and close start function then there are 2 buttons that act as trigger microswitches to tell the actuators when to operate. I am using H bridges to control the actuators in forward and reverse. 2 of the relay outputs control forward and reverse for one set of rams on either side of the bonnet the other 2 relay outputs do the same except on another pair of rams. The issue I have is that you can press the open button and once after a few seconds you hit the microswitch button to enable the second set of rams but at this time the first set of rams go into reverse for a time and the sequence finishes...the opposite or closing sequence works just as I want it as basically this is just a reversal of the opening proceedure. BUT once you hit the open sequence and after it is finished you can engage another open sequence which will create a big problem. What I need to do is to have them run sequencially.
You start the open sequence and once it is finished you can only then hit the closing sequence and once that is done you can only hit a open sequence etc etc...I have been trying to work out how I can do this. I looked at using the Connection Icon but couldnt get it to work. Any suggestions to point me in the right direction please.

I am pretty happy with what I have done so far and have learnt heaps doing this. The Miac is a pretty sweet bit of kit

Mark
Attachments
OUT2_v6_working.fcfx
(12.01 KiB) Downloaded 610 times

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

Re: Can someone tell me where I have gone wrong

Post by medelec35 »

Hi Mark,
markkkk wrote:The Miac is a pretty sweet bit of kit
I would agree with that.
I have three of them,
Each doing a different job, and doing it really well.

If it was me I would create a switch Inhibit variable, Bool type will suffice.
Then I would place a decision icon (If Inhibit) so that only no branch contains switch input
All the time you don't want switch to be accidently pressed set Inhibit variable to 1
As son as sequence has ended and switch is allow then set Inhibit to 0

Hope this helps

Martin
Martin

markkkk
Posts: 21
Joined: Fri Jul 28, 2006 3:30 am
Location: Brisbane Australia
Contact:

Re: Can someone tell me where I have gone wrong

Post by markkkk »

Hi Martin

I have been trying to get the boolean to work for a couple of days now...buggered if I know what I am doing wrong...just cant seem to get my head around the sequence of what you said. I am looking through the examples to see if I can find something similar to help understand it properly. Once it gets into my thick skull then it usually stays there :)

Mark

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

Re: Can someone tell me where I have gone wrong

Post by medelec35 »

The bool is just one of the type of variables you can select when adding a new variable.
Other types are int, string etc.
I was curious about one thing, when you first power Miac up, should it be checking for ram position first so the wrong button cant be pressed by accident?
That can be done my checking status of the micro switch.
Would it be better if delays are removed and just stop ram only when correct micro switch is activated.
Also while ram is opening for example would it be a good idea to allow the close switch to operate and vice versa.
Just in case you change ram direction due to some issue?
Martin

markkkk
Posts: 21
Joined: Fri Jul 28, 2006 3:30 am
Location: Brisbane Australia
Contact:

Re: Can someone tell me where I have gone wrong

Post by markkkk »

Hi Martin

I understand the types and differences of the variables no problem but Boolean has always screwed with my head for some stupid reason
All the rams have internal limit switches which stop it at the positions fully open and fully closed as you want them to as sort of a electrical/mechanical stop so they cant be overdriven. When you push the open button (trigger) the bottom ram goes forward until it hits the microswitch (trigger3) when this happens the top ram then goes forward until it hits its internal limit at the same time the bottom ram then goes into reverse until it hits its internal limit switch . The delays are just for demo use in the program to simulate actual timed operation of the rams the relay on and off commands will be set in software timing when on the actual hotrod. The closing mode (trigger2) is the same for the bottom ram and when it hits the other microswitch (trigger4) the top ram is set in reverse unit it hits its internal limit switch.

The issue is that I can hit the open or close command after each one cycle...and it can not be like that it can only ever be a open cycle then a close cycle and then a open cycle and then a close cycle. This is what I am having trouble with. I have tried to do it sequentially with the chart but I couldnt get it to work so it probably needs some sort of and/or logic or as you suggested some boolean to do this. I have tried to find examples somewhere but have not been able to find anything like that so far in all the examples I have downloaded

Mark

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

Re: Can someone tell me where I have gone wrong

Post by medelec35 »

Hi Mark,
I'm only asking the questions e.g
medelec35 wrote:I was curious about one thing, when you first power Miac up, should it be checking for ram position first so the wrong button cant be pressed by accident?
That can be done my checking status of the micro switch.
So I can modify the flowchart for you.
If one or the other switch is closed on start up every time then that would send me in a direction to do modify your flowchart.
Also what would happen if during ram movement power has failed then restored?
Would one of the microswitches still be closed indicating that ram is on its limit?
Martin

markkkk
Posts: 21
Joined: Fri Jul 28, 2006 3:30 am
Location: Brisbane Australia
Contact:

Re: Can someone tell me where I have gone wrong

Post by markkkk »

Hi Martin

Sorry I misunderstood.

The trigger and trigger1 variables are momentary pushbuttons they are the open and close push buttons on the dash of the car. I dont have any way easily of making sure the bonnet is open or closed but I can add of course on the spare inputs another microswitch to detect when the bonnet is actually closed and another when it is fully open as there are still 4 inputs left.

Mark

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

Re: Can someone tell me where I have gone wrong

Post by medelec35 »

Hi Mark,
The current ram end detections should suffice.
I have modified your flowchart so only open will work when closed switch is on (ram position switches not momentarily type anymore) or vice versa
All components have been moved to system panel so you can clearly see switch positions.
To start, if you want ram to close make sure open ram micro switch is closed first.

Hope this is more what you're after.


Martin
Attachments
OUT3_v6.fcfx
(15.9 KiB) Downloaded 581 times
Martin

markkkk
Posts: 21
Joined: Fri Jul 28, 2006 3:30 am
Location: Brisbane Australia
Contact:

Re: Can someone tell me where I have gone wrong

Post by markkkk »

Hi Martin

That shows me heaps of how to do quite a lot of things. This is what I was after to help me understand the sequencing and how to actually write the anding functions. The simulation crashes flowcode completely after about 1or 2 mins or so but it works and I see the mechanism you are using to do it. Not sure why flowcode is crashing as everything seems to work fine in the simulation but what you have done will allow me to get heaps further with learning this. Thanks a lot it is much appreciated. I am about to make up the Hbridges this weekend so hope to have the system actually working next week. Steve's hotrod will be back from the exhaust shop next week so then I can get access to it to try it all actually on the car.

Mark

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

Re: Can someone tell me where I have gone wrong

Post by medelec35 »

Hi Mark,
No problem, gald I can help.
By the way if you want to use

Code: Select all

OR
then just use the pipe character twice:

Code: Select all

||
markkkk wrote:The simulation crashes flowcode completely after about 1or 2 mins or so
Opps sorry,
Forgot to add a 100ms delay anywhere in the main loop.
Add that and flowcode should no longer crash during simulation.
Although it's a bug that affects simulation only,
It's good practice to have the delay when running hardware.
Prevents LCD from being updated too quickly.

Martin
Attachments
OUT4_v6.fcfx
(15.97 KiB) Downloaded 599 times
Martin

Post Reply