November 24, 2024, 04:35:47 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


HB25 and PING))) wiper motor control

Started by wandererrob, October 21, 2011, 10:13:54 PM

Previous topic - Next topic

wandererrob

OK, I realize these are two Parallax units but I'm controlling them with a Prop-1 so I figured it's worth picking some brains here too.

I've got a wiper motor setup a la Scary Terry http://www.scary-terry.com/wipmtr/hb25demo.jpg, but for added fun, I'm using a PING))) sensor as a trigger. I almost have it working but not quite. I'm having some code issues. I want this to open a trunk lid when a person is within a certain range and when they get even closer, have it close again. Think "something peeks out at them but then hides again when they get too close".

I've got it reacting to my test ranges, but the trouble is the inside the given range it "opens" then it opens again, and again until it gets the "close" command. It then keeps trying to close every few seconds until something changes again. I can't get it to open, then wait until they get closer, then close. And the same as they walk away. Open, then close as they get out of range again. What am I missing?

I should mention I'm still fairly new to coding this stuff so I'm not very good at it. ;D

That said, here's what I've got so far (see attachment). Thanks for any help you guys can provide!


wandererrob

As a side question... why does Scary Terry's Prop-1 say Parallax on it?  :o

JackMan

The problem is your GOSUB Get_Sonar command. As soon as one of your criteria in that GOSUB is met it carries out that function but immediately goes back to the GOSUB Get_Sonar because the RETURN command takes it back to your Main section. This causes the motor to keep repeating which ever condition is present with the PING.

wandererrob

October 21, 2011, 11:06:42 PM #3 Last Edit: October 21, 2011, 11:16:26 PM by wandererrob
Quote from: JackMan on October 21, 2011, 10:40:24 PM
The problem is your GOSUB Get_Sonar command. As soon as one of your criteria in that GOSUB is met it carries out that function but immediately goes back to the GOSUB Get_Sonar because the RETURN command takes it back to your Main section. This causes the motor to keep repeating which ever condition is present with the PING.

OK, that makes sense. How do I stop that from happening without bringing the program to a grinding halt? That is to say, how do I go about telling it to open when somebody is X distance away then wait until they get y distance away before you close?


Here's a modified version based on some other feedback I've gotten, but this one works... less well (which isn't saying much  ;D)

JackMan

October 21, 2011, 11:15:26 PM #4 Last Edit: October 21, 2011, 11:23:53 PM by JackMan
Not sure if this will work but give it a try.
(I forgot a line of code in the first file, use this one instead)

bsnut

Quote from: wandererrob on October 21, 2011, 10:14:43 PM
As a side question... why does Scary Terry's Prop-1 say Parallax on it?  :o
Jon and John used to work at Parallax they designed the Prop-1. When Parallax stop selling EFX product line they moved on to start what you see today, that is EFX-TEK.

Don't be surprised to see an RC-4, DC-16 or a Prop-2 with Parallax's name on. They were also designed by them and they almost can be called antiques ;D.   
William Stefan
The Basic Stamp Nut

wandererrob

Quote from: JackMan on October 21, 2011, 11:15:26 PM
Not sure if this will work but give it a try.
(I forgot a line of code in the first file, use this one instead)

No dice at the moment, but I think I see where you're going with it. You've sent me in a new direction. It hadn't occurred to me to approach it in this... more stepwise manner, for lack of a better term. But that does make more sense to me. I'll muck around with this a bit more today and see if I can get it working.

Thanks for the nudge.

bsnut

Here is a another nudge for you and that is. Look at the HB-25 motor controller and Ping sensor PDF's for example code, which should help you with Jack's code.
William Stefan
The Basic Stamp Nut

wandererrob

Quote from: bsnut on October 22, 2011, 02:03:35 PM
Here is a another nudge for you and that is. Look at the HB-25 motor controller and Ping sensor PDF's for example code, which should help you with Jack's code.

That's exactly what I did and this resulted in the attached revision of Jack's code, which is working the way I want it to. Now I just need to get the timing of the motor fine tuned so it only goes 180*, stops, then goes -180*.

I'm *this* close on the timing, but can't quite seem to home in on it yet. I don't think wiper motors were meant to do this  ;D

Any suggestions that might help fine tune the motor movement control a bit?

Thanks, guys. You've been a huge help so far!

JackMan

Well, this is a bit of work, but end switches set up on the motor linkage is another option. This will give you positive control of the motor travel. You may not even need the HB-25.

wandererrob

Hmmm... That's an idea too. I've already got the code set now (in no small part thanks to your help! Thanks again!), but it might not be that difficult to integrate a couple of momentary switches as triggers. Put the high and low limit switches on separate pins, add a line or two of code to tell the HB25 to stop when each switch is triggered.

But alas, I only have 4 days left and still have a cemetery and crypt to build and a house to finish decorating.

That'll teach me to start a new project 2 weeks from the big night. LOL!


bsnut

October 24, 2011, 11:12:36 PM #11 Last Edit: October 24, 2011, 11:27:25 PM by bsnut
QuotePut the high and low limit switches on separate pins, add a line or two of code to tell the HB25 to stop when each switch is triggered.
Here is the added  I/O for the limit switches.

' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL Ping = 6
SYMBOL Openlimit = PIN2 'Normally Open Switch
SYMBOL Closelimit = PIN1 'Normally Open Switch
SYMBOL HB25 = 0

Here is the open limit code and I only added two lines of code.

lid_open:
FOR index = 150 TO 171                  ' Ramp Up To Full Speed
  PULSOUT HB25, index                    ' Motor Forward
  PAUSE 150                              ' 150 mS Smoothing Delay
  IF Openlimit = 1 THEN lid_opened       ' open limit
  NEXT
  PAUSE 400

Lid_opened:                              ' stops here when lid is open "Lid_opened"
FOR index = 171 TO 150 STEP -1          ' Ramp Back Down
  PULSOUT HB25, index                    ' Motor Forward Slowing
  PAUSE 125                              ' 150 mS Smoothing Delay (my need to change)
  NEXT

Here is the close limit code.

lid_close:
FOR index = 150 TO 130 STEP -1          ' Ramp Up To Full Reverse
  PULSOUT HB25, index                    ' Motor reverse
  PAUSE 150
  IF Closelimit = 1 THEN Lid_opened       ' close limit
  NEXT

Lid_closed:                              ' stops here when lid is closed "Lid_closed"
  PAUSE 337                              ' 150 mS Smoothing Delay
  FOR index = 130 TO 150                 ' Ramp down To stop
  PULSOUT HB25, index                    ' Motor reverse slowing
  PAUSE 150                              ' 150 mS Smoothing Delay
  NEXT
GOTO main

Remember to put the limit switches near the end of travel of the lid. This way the motor has time to coast down to a full stop and may need to adjust the smoothing delay.
William Stefan
The Basic Stamp Nut

wandererrob

Thanks! That'll be a huge help.

Assuming I don't need to fix anything in the haunt Sunday, I think I know what Sunday's project will be.

;D

wandererrob

October 09, 2012, 02:03:50 PM #13 Last Edit: October 09, 2012, 02:50:52 PM by wandererrob
Greetings once again, my tech savvy friends!

Well, seeing as I've dug up this old thread, I bet you can see where this is going :)

I never got it working, shelved the project, then forgot about it for several months. And here I am once again. A year old, Halloween closing in fast and this project laughing at me once again.

So, picking up where we left off, I tried the limit switch code above and various renditions thereof to no avail. I even tried to scale back and just get the HB25 to respond to triggering from a switch. Specifically just PULSEOUT HB25, 130 (as a speed/direction example) then having it stop when triggered. But it's like the switch just isn't there. I don't think i need the ramping for this application really, just "go" and "stop". Go I can make happen. Stop when the switch is closed, not so much.

Anybody willing to take a whack at this dead horse? I'd be eternally grateful :)


EDIT: Wait, Nevermind. I think it just clicked. Much like taking a dog to the vet. I just had to show up and asdk and voila! All better!

By Jove, I think we've got it!

bsnut

QuoteEDIT: Wait, Nevermind. I think it just clicked. Much like taking a dog to the vet. I just had to show up and asdk and voila! All better!

By Jove, I think we've got it!
From what I'm reading from your EDIT. You got everything working the way you want it is this correct?
William Stefan
The Basic Stamp Nut