Home 2018 Forums Crumble Support Simple buggy motor control

Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2216
    killerwhat
    Participant

    Have made input A run motor 1 forward (if A is Hi then Motor 1 Forward else Motor 1 Stop) & input B run motor 2 forward but if I try to use inputs C & D to run 1 & 2 in reverse I get a wierd pulsing effect and they wont go in reverse??
    Help please

    #2217
    killerwhat
    Participant

    Crumbuggy code:

    https://www.dropbox.com/sc/m0yjx666aoltgk2/AADkFBmyNgIxMh539fyIYaypa

    • This reply was modified 5 years, 4 months ago by Simon. Reason: add image
    • This reply was modified 5 years, 4 months ago by Simon. Reason: remove img as it didn't work
    #2219
    Joseph
    Keymaster

    I suspect as the program runs through the loop, both ‘else’ sections are being executed and turning the motor off, hence the pulsing.

    You could fix this by adding an ‘if C low’ in the else section of the if A statement.

    Alternatively, you could change the program so it deals with the four combinations of each input separately. So for motor 1:

      A: HI C: LO — Motor 1 Forwards
      A: LO C: HI — Motor 1 Reverse
      A: LO C: LO — Motor 1 Stop
      A: HI C: HI — Motor 1 Stop (or could set forward)

    I’ve just enabled attachments, so you can now upload your program. I’ll try and attach and image now…

    Hope this helps!

    Joseph

    Attachments:
    You must be logged in to view attached files.
    #2222
    killerwhat
    Participant

    Thanks Joseph
    I’ll give it a try.
    Regards
    Steve

    #2223
    Joseph
    Keymaster

    No problem 🙂
    It looks like my Crumble file didn’t attach – will try again…

    Attachments:
    You must be logged in to view attached files.
    #2241
    Mike
    Participant

    Depends a bit on what you have attached to A, B, C and D… What is the hardware setup? 🙂

    #2244
    killerwhat
    Participant

    All sorted. The code that Joseph attached worked perfectly.
    I have 4 little PTM switches on a board with one side of each commonly connected to a croc lead to be clipped to +ve the other 4 sides to crocs for clipping to A,B,C & D

    #2245
    Mike
    Participant

    Yup – just looked at the code again and as Joseph said, you’re making the motor move, then a bit further on in the code you are stopping the same motor. I think the attached is about the shortest solution…

    Attachments:
    You must be logged in to view attached files.
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.