Announcement

Collapse
No announcement yet.

Conveyor width adjustment using Pic 16f877A (AC motors, LCD, Button, Switch, Relay)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Conveyor width adjustment using Pic 16f877A (AC motors, LCD, Button, Switch, Relay)

    Hello,
    I write code and draw circuit diagrams (copy from other code on the network), but there are some places that have not been processed yet,
    Request:
    This circuit I use to open the relay, control the forward (out) control (in) for AC motor and display the rotation value on the LCD with the corresponding "MM" unit, and be limited to two Switches.
    I'm in trouble,
    - If Switch_out is turned on, hit Move_out does not work, only Move_in press works. Switch_out off then both (move_in and move_out) work
    - or Switch_In is turned on, Move_in pressing no effect, only move_out works. Switch_in off, both (move_in and move_out) work
    Do you have a way to save the current value on the LCD when you turn it off?,
    If not, I think I need to do a home button, when I turn on the device, pressing the Home button to Move_out will automatically turn until the Switch_out switch stops and display a certain value.
    Any sugesstion? Perhaps someone else has an example or modify code?
    (I would like to attach a simulation file with Proteus or a reference image but the website currently reports, I am not yet entitled, sorry for the inconvenience, so I just put the Code on the article.)
    Code:
    PHP Code:
    '@ device xt_osc ; oscilador externo XT
    define osc 4 ; 4 Mhz
    Define LOADER_USED 1
    ; Definicion de conecciones del LCD
    Define LCD_DREG PORTD
    Define LCD_DBIT 4
    Define LCD_RSREG PORTA
    Define LCD_RSBIT 0
    Define LCD_EREG PORTA
    Define LCD_EBIT 1
    pos var word ' position
    delay var PORTC.1 ' Alias first delayOut pin
    delay1 var PORTC.2 ' Alias first delayIn pin

    ADCON1 = 7 ' PORTA and PORTE to digital
    Low PORTA.2 ' LCD R/W low = write
    Pause 500 ' Wait for LCD to startup

    OPTION_REG = $7f ' Enable PORTB pullups
    LOW delay ' portc.1 como salida para controlar el servo
    LOW delay1
    Gosub center ' Display origin
    portB = 0 ' PORTB lines low to read buttons
    TRISB = $fe ' Enable first button row (RB0=output=LOW)
    main:
    if portb.4=1 then ' Move_Out
    LOW delay
    else
    high delay
    GOSUB out
    endif

    if portb.5=1 then ' Move_in
    LOW delay1
    else
    high delay1
    GOSUB in
    endif

    Lcdout $fe,1
    Lcdout $fe,2,"WIDTH = ",#pos,"mm"
    Lcdout $fe, $c0, "CONVEYOR ADJUST"
    Pauseus 1000 + pos
    Pause 500
    goto main
    out:
    If pos < 5000 Then
    pos = pos + 1
    Endif
    RETURN
    in:
    If pos != 0 Then
    pos = pos - 1
    Endif
    RETURN
    center:
    pos = 500
    Return
    End

    Thanks!.

  • #2
    Hello everybody!
    Sorry, maybe I mistakenly wrote the article to another forum,
    I would like to write back to this forum.
    "PBP3 (PicBasic Pro 3.0)
    Please post questions about PBP3 in this forum. "
    Thanks!

    Comment


    • #3
      Do you have a way to save the current value on the LCD when you turn it off?,
      the usual way would be to write the value displayed to eeprom or some other non volatile memory {WRITE} before shutdown and to recall that value [if set] from the same said memory {READ} upon power up /reboot

      Comment

      Working...
      X