DC Motors

Post and discuss new components that you have created.
Post Reply
fwall
Posts: 1
http://meble-kuchenne.info.pl
Joined: Wed Nov 10, 2021 11:40 pm

DC Motors

Post by fwall »

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

BenR
Matrix Staff
Posts: 1726
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 438 times
Been thanked: 602 times

Re: DC Motors

Post by BenR »

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.

medelec35
Matrix Staff
Posts: 1449
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 509 times
Been thanked: 472 times

Re: DC Motors

Post by medelec35 »

Hi.
If you are interested, I posted an example on this post.
Martin

chipfryer27
Valued Contributor
Posts: 1142
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 282 times
Been thanked: 412 times

Re: DC Motors

Post by chipfryer27 »

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 :)

PD1404
Posts: 1
Joined: Thu Nov 24, 2022 2:27 pm

Re: DC Motors

Post by PD1404 »

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.
Attachments
DCmotor not working.docx
(75.12 KiB) Downloaded 142 times

Steve-Matrix
Matrix Staff
Posts: 1249
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: DC Motors

Post by Steve-Matrix »

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.

Post Reply