Hi there,
I am trying to use the DC motor component in my code and I need it to move for 10 seconds. I have tried using the component macros forwards(10) and coast but is seeming to stop early, of if I use forwards(1) it won't stop! Would greatly appreciate if someone could explain how they function and how I can best code them to rotate forwards for 10 seconds and also backwards for 10 seconds. I can't find much online.
Thanks in advance
DC Motors
-
- Matrix Staff
- Posts: 1760
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 447 times
- Been thanked: 607 times
Re: DC Motors
Hello,
The number assigned is the speed when using PWM or HBRIDGE control method. For simple on/off the number will make no difference.
Sounds like your program needs to do the following.
Forwards (1)
Delay S (10)
Stop ()
You might need a further delay at the end, if you're inside a loop with no delay at the end then we will go straight back into Forward which will appear like the Stop function never got called.
Hope this helps.
The number assigned is the speed when using PWM or HBRIDGE control method. For simple on/off the number will make no difference.
Sounds like your program needs to do the following.
Forwards (1)
Delay S (10)
Stop ()
You might need a further delay at the end, if you're inside a loop with no delay at the end then we will go straight back into Forward which will appear like the Stop function never got called.
Hope this helps.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Valued Contributor
- Posts: 1189
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 289 times
- Been thanked: 418 times
Re: DC Motors
Hi
Have you looked at the component example yet?
https://www.flowcode.co.uk/wiki/index.p ... C_Motor_()
How are you connecting your motor? The example is for a Full-Bridge config. If you can share your flowchart and how you are connecting (even if just simulation) I'm sure the forum can assist.
Regards
Edit...
Seems Ben and Medelec beat me to posting <s> Generally speaking, always do as they suggest
Have you looked at the component example yet?
https://www.flowcode.co.uk/wiki/index.p ... C_Motor_()
How are you connecting your motor? The example is for a Full-Bridge config. If you can share your flowchart and how you are connecting (even if just simulation) I'm sure the forum can assist.
Regards
Edit...
Seems Ben and Medelec beat me to posting <s> Generally speaking, always do as they suggest
Re: DC Motors
Hi,
When I use a program as mentioned by others. I am getting a message as 'one or more pins of component motor-full bridge 2 are not connected to the microcontroller.
Can anyone tell me what I have to do to rectify this issue.
When I use a program as mentioned by others. I am getting a message as 'one or more pins of component motor-full bridge 2 are not connected to the microcontroller.
Can anyone tell me what I have to do to rectify this issue.
- Attachments
-
- DCmotor not working.docx
- (75.12 KiB) Downloaded 169 times
-
- Matrix Staff
- Posts: 1276
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 170 times
- Been thanked: 285 times
Re: DC Motors
Right-click the motor component and select "properties". Then in the Properties window make sure any pin connections are correct. Each one will either start with a "$" or be labelled as "Unconnected". Ensure that all of these are correctly assigned to a valid pin for your microcontroller by clicking on the port/pin value (or the "unconnected" text) in the right column of the property list.