Reacting to a change in distance.

LimeTree.

New Member
The dream

I have a machine that guides wire onto a reel, to do this it needs a tension arm which is controlled by slowing down or speeding up a motor.

My idea is to automize this.

My reason for this post is that I have no background in electrical engineering and im doing this as a little project. So, just looking for some reassurance!

Solution?
I aim to do this by having a PICAXE 28x1 send a 'trigger' signal to the SRF05 Ultrasonic sensor to send out a signal to this tension arm and then when the signal bounces back for it to send an "echo signal" to the PICAXE and from this calculate the distance the arm is away from the sensor (if we know the miliseconds it takes for this signal to return, then we can calculate the distance). Once the distance is found the program on the PICAXE should then send a signal to a digital potentiometer (MCP4011) which will then either lower the voltage or increase it, thus changing the speed of the motor.

Below is a picture of the basic circuit design... I apoligise for the poor quality, but unfortunately i have no current access to any circuit imaging software like PCB wizard etc


The standard potentiometer (bottom left corner) is what is currently used to control the motor. Im assuming I can just hook the MCP4011 straight upto the inlets and outlets of the standard one?

Does it look like a resonable idea? Have I made any gaping mistakes?

Your feedback is much appreciated, thank you!

~Luke



Oh.. Once I've got this working and tweaked it a bit i'll make everything opensource for anyone to use should they so wish. :)
 
Last edited:

hippy

Ex-Staff (retired)
Welcome to the PICAXE forum.

It sounds possible but it may be a little complicated and more difficult to use in practice than alternatives.

A more common method of determining the position/angle of the tension arm would be to fit a pot to the arm ( or a pot on another spring loaded arm which can rest against that ) rather than using an ultrasound sensor. That will likely give a more reliable reading and be more responsive.
 

LimeTree.

New Member
Thank you very much for your reply!

Sounds daft from my end, but this idea didn't actually occur to me (now that iv'e ordered the bits) .

If my idea doesn't work out for some reason I will be sure to give this a go!
To be perfectly honest, even if it does work I may still change it to your plan.

Kind regards,
Luke
 

hippy

Ex-Staff (retired)
The MCP4011 was a little more complicated than I was expecting ...

http://ww1.microchip.com/downloads/en/DeviceDoc/21978c.pdf

However, it seems it's really only a case of setting U/D ( high to increment, low to decrement ), setting CS low, issuing a PULSOUT on U/D for each desired wiper change, setting CS high when done.

As with all projects; best way is to do it in separate parts, get the SRF005 sensor working, get the MCP4011 control working ( either order), then combine the two to produce the final application.
 

LimeTree.

New Member
Once again, thank you for your input.

Code:
; Define the PICAXE Digital Outputs

symbol CS  = 26            ; the MCP4011(digital potentiometer) CS pin connects to PICAXE output pin 26
symbol UD  = 24            ; the MCP4011 U/D pin connects to PICAXE output pin 24
symbol RLED = 2
symbol GLED = 3					;!!!!!!! On actual programmed pic (x2 not x1) change "=24" and "=26" to "=A.24" and "=A.26" . I have it as just "=24" etc as
; the simulator on this program reuires it.!!!!!!!!

; Define the initial conditions
symbol trig = 11 'Define output pin for Trigger pulse 
symbol echo = 12 'Define input pin for Echo pulse 
symbol range = w1 '16 bit word variable for range

Init:
    HIGH CS            ;    set the chip select high to disable serial control.

    
main:
pulsout trig,2  'produce 20mS trigger pulse (must be minimum of 10uS)
pulsin echo,1,range  'measures the range in 10mS steps
pause 20 'recharge period after ranging completes

;let range = 200     ; this line of code makes the distance away = 17cm... thus going to decrement
let range = range * 10 / 58 ;divide by 2 if PICAXE 28x2 instead of PICAXE 28x1
sertxd (#range) ;displays value returned by "range"

If range < 8 then goto Increment  ;if the range is less than 90mm then Increase Resistance
If range > 10 then goto Decrement ;if the range is more than 100mm then Decrease Resistance

goto main 



Decrement:
    HIGH RLED            
    LOW UD            ; set U/D pin to low state to indicate decrement mode
    LOW CS           ; set CS pin low to enable serial control of the MCP4011

    PULSOUT UD, 1        ; 1 msec pulse on the UD line to step down

    HIGH CS    ; Finished stepping down so must set CS pin high before can select a new mode.
    LOW RLED
GOTO Main

Increment:
    HIGH GLED 
    HIGH UD ; set U/D pin to high state to indicate increment mode
    LOW CS  ; set CS pin low to enable serial control of the MCP4011

    
    PULSOUT UD, 1     ; 1 msec pulse on the UD line to step up
    
    HIGH CS      
    LOW GLED    
GOTO Main
This is the piece of code I have so far, some of this code is my own and some of it i have found from forums etc and just pieced it together.



The MCP4011 was a little more complicated than I was expecting ...
Isn't it just! I was hoping for just two signals, one to step up and one to step down. But alas...
 
Last edited:

LimeTree.

New Member
Got all the components today and so far ive got the picaxe talking to the srf005 and can control a few led's dependant on what distance you put your hand away from the sensor etc :)

Pretty happy with that!

Now just gotta see if the potentiometer works
 

LimeTree.

New Member
Update..


The program now controls voltage going through the mcp4011 pot :)

Traverse Circuit.JPG

Above is the circuit diagram i used...Coudnt find a layout of the mcp4011 so used a dil with the same number of pins and im just hoping for the best really... will get it to fit somehow haha.

PCB is on order from pcbtrain.. they were the cheapest costing £58 for the one pcb board.
Others where charging £80 for a tooling cost and then you had to purchase 15 boards at £10 each.. so PCBtrain seems the best from what ive seen.

Still awaiting the board though, should get it by the 11th!

Anyone needs any information on anything i've done feel free to ask. Though I am very much a newbie to this myself.

Regards,
Luke
 
Top