Shop OBEX P1 Docs P2 Docs Learn Events
Programming Question — Parallax Forums

Programming Question

ajs2001txajs2001tx Posts: 25
edited 2005-09-29 15:54 in BASIC Stamp
Ok, here goes......

I need a pin to take input from a shaft enocder while a part is moving and count·3 feet of movement or·3 seconds whatever comes first as·a safety feature.· Is there a way to do both of these at the same time so there is smooth movment and not jerky stopping to calculate?·

Thanks

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-09-29 04:00
    ajs2001tx -

    Implicit in your question seems to be a fact that's not clearly stated. Is the Stamp contolling the movement of this device completely, or is it just able to start/stop it? If so, what kind of motor is being driven, and is there an off-Stamp board motor controller driving it?

    I suspect there will be a few other questions that need to be asked, but let's start there.

    Regards,

    Bruce Bates
  • ajs2001txajs2001tx Posts: 25
    edited 2005-09-29 12:17
    Yes the stamp has complete control.· It is controlling a set of hydraulic solenoid valves which move a·cart forward and back on a track via a hydraulic orbit motor.· The encoder will be attached to the shaft of the chain drive that transmits the power from the orbit motor to the cart.· I want to add the time constraint as a safety device incase something gets in the way of the·cart so it wont crush it trying to get to the 3 feet or any other distance goal.· So that being said, the time needs to be master and distance measured the slave.· However I do not want the press to move any further than the specified distance in the specified time.· Does that make more sense?

    Thanks
  • Alan BradfordAlan Bradford Posts: 172
    edited 2005-09-29 13:20
    Hi,

    I·have done this type of control with a stamp based system. Easier than mounting a rotary encoder, use an optical counter, or hall device to count the links of the chain, or teeth on the drive gear. This will allow the Stamp to have an easier time to do both distance and time measurements.

    I assume the 3 foot distance takes 1-2 seconds and the 3 seconds is a safety backup.

    I would use a simple routine like this:

    x=0

    Move_Whatever:

    (Turn on Solenoid Here)

    x=x+1

    pause 1

    (Monitor safety circuit here)

    (Count Pulses for distance measurment)

    If Dstance_Traveled = 3_Feet then Other_Process

    if x < 3000 then Move_Whatever

    Other_Process:

    Continue program here.



    You may need to adjust the 3000 count to make the time 3 seconds.

    If a more accurate time is needed then use a timer chip and compare times.

    I use this timng setup for lots of industrial machinery where the timing is not super critical. 3 Seconds +/- .1 second is easy to acomplish without adding an external timer.

    Alan Bradford

    Plasma Technologies
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-09-29 13:26
    ajs20001tx -

    My backgound is not with hydraulically operated systems, short of my using the hydraulic systems on my tractor, so if I wander astray here, just yank my leash back. My thinking may well be electro-mechanical in nature, due to that past experiance - sorry.

    I'm starting to get a better picture. Is the general motion of this "machine" continuous, and circular (endless loop or conveyer belt like) or only reciprocal (back-and-forth)? I realize you said the cart goes back and forth (reciprocal), but I was hoping to look at the larger picture, if there is one to be seen. The reason I ask is that the length or distance presently travelled seems to be purposely and I presume rather accurately contrained, or could be, simply by the use of electro-mechanical limit switches or just by mechanical stops How is that presently and actually occurring?

    With the above in mind, how can or does "overrun" occur, or isn't it overrun that's the actual concern?

    Presuming there is a change of direction in this action, due to its reciprocal rather than circular action, what presently prompts for that change? This may be the same thing you answered above; my apologies if it is.

    I'm kind of getting the feeling that you're looking to electrically/electronically automate what is presently may be a partially or wholly manual, (hydraulic-)mechanical system. Is that indeed the case?

    Any chance of getting a static picture or short "movie" of the "machine". Even a web site link may be enough so that I can better picture this guy. Sometimes it's a pain for others, as I'm primarily a visual learner smile.gif

    Here's my general but most pressing concern - you can do many things concurrently on a Stamp or other microprocessor. What you can NOT do (generally) is two things simultaneously. I suspect concurrency (multiple things done during the SAME PERIOD of time) is all that's needed here and not simultaneity (two things being done, or occurring at, the EXACT SAME time). Your point and sage observation in your last post above, that "the time needs to be master and distance measured the slave" implies or affirms one-than-the-other (serial) operation which can obviously be a concurrent set of operations. Since there are obviously safety issues here, I'd rather be SURE before I said YES definitely, but tentatively I'm headed in that direction. I'll sketch up a short flow chart to show you how I'd go about this.

    Regards,

    Bruce Bates
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-09-29 15:54
    ajs2001tx -

    I may have found the perfect solution for this application, regardless of the motion, operation, or how it's configured. My other unstated concern in my last post, was having the Stamp have "too much on its plate" to operate efficiently and reliably. Specifically, fielding encoder input can be a very tedious and an often time consuming task, as it must be over the Nyquist Limit for reliability, and you have other equally pressing, time related tasks at issue (3 second time limit), as well as event limits (36" of travel), and perhaps even more I don't even know about. All of those issues are directly or indirectly time related. Unloading the Stamp processor by using an external chip seemed like an appropriate approach to this problem.

    Maxim-Dallas makes a wonderful little chip that was born for process control, in my estimation. Take a look at the DS-2404 (link below), which should take care of most or all of the external needs (timing and event control), leaving the Stamp to perform other tasks, and for it to only check this external chip for an interrupt occasionally. You also get a host of other benefits from this chip, which may or may not be important to you. Here are some of them, for those who don't wish to grab the data sheet:

    4096 bits of nonvolatile dual-port memory including real-time clock/calendar in binary format, programmable interval timer, and programmable power-on cycle counter

    1-Wire interface for communication at 16.3kbps - AND -

    3-wire host interface for high-speed data communications at 2Mb/s

    Unique, factory-lasered and tested 64-bit registration number assures absolute traceability because no two parts are alike

    Programmable alarms can be set to generate interrupts for interval timer, real-time clock, and/or cycle counter

    Battery back-up provisions for uninterrupted operation

    16-pin DIP, SO, and SSOP packages

    If you're using a more advanced Stamp, with OWIN / OWOUT commands availabe to you, you can use the onboard Dallas 1-Wire interface. If not, use the 2/3 wire synchronous serial interface with SHIFTIN / SHIFTOUT. It's almost like they had the full range of Stamps in mind when they designed this wonderful little chip! smile.gif

    Use the interval timer for your 3 second time window, and use the cycle counter (via the encoder count) to limit the travel. All you need to then do is check to see if an interrupt occurred, and if so, which one (interval or cycle count or both), and take appropriate action.
    What could be easier!

    The interval value is 5 BYTES long, and the cycle counter is 4 BYES long, affording a good deal of range. Even if that weren't the case, it's easy enough to count the (lesser - more frequent) interrupts on the Stamp, and react/respond when some time/count multiple occurs.

    I hope this chip works out for you - it's less than $10.00 US in ONE OFF quantity and samples are available from Maxim-Dallas. Here are the pertinant links below:

    Maxim-Dallas: http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2904/ln/

    Newark Electronics: http://www.newark.com/ ( search for part number DS-2404* )

    Regards,

    Bruce Bates
Sign In or Register to comment.