• AVR Freaks

Helpful ReplyPIC24FJ64GA102 : I/O pins not working as i would to drive an actuator

Author
nrobin
New Member
  • Total Posts : 11
  • Reward points : 0
  • Joined: 2019/11/21 04:03:23
  • Location: 0
  • Status: offline
2020/01/13 02:08:08 (permalink)
0

PIC24FJ64GA102 : I/O pins not working as i would to drive an actuator

Hello,
 
i would like to drive an actuator. I used 2 signals Verin_Sens (pin RB2) and Verin_ON (pin RB11).
The driving of these 2 signals are done in _SPI1Interrupt()
To know the position of the actuator, 2 signals are listened to : signal VerinSignA on RB4 and Verin SignB on RA4.
For the moment, only RA4 is treated in CNInterrupt().
To open the actuator, i write RB2 = 1 and RB11 = 1. To close it, i write RB2 = 0 and RB11 = 1.
 
The actuator is driven when you push a button on pin RB9.
 
One problem is even if i wrote 0 on RB11, the actuator kept on going in the same direction without stopping.
 
Is anybody can help me to find what is wrong in my code ?
 
The applicaiton is attached (BDCOrder2.zip)
 
#1
ric
Super Member
  • Total Posts : 25244
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: PIC24FJ64GA102 : I/O pins not working as i would to drive an actuator 2020/01/13 02:20:26 (permalink) ☄ Helpfulby nrobin 2020/01/13 02:37:55
0
Write to LATx registers, not PORTx registers.
That means, change
    _RB2 = 0;
to
  _LATB2 = 0;
 
    _RB11 = 0;
to
    _LATB11 = 0;


    _RB15 = 1;
to
    _LATB15 = 1;


 
and so on.
Only every use the Rx# form (which access the PORTx register) when you want to read a port, NOT for writing.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#2
nrobin
New Member
  • Total Posts : 11
  • Reward points : 0
  • Joined: 2019/11/21 04:03:23
  • Location: 0
  • Status: offline
Re: PIC24FJ64GA102 : I/O pins not working as i would to drive an actuator 2020/01/13 02:37:44 (permalink)
0
Thank you ric for the answer and advice.
 I made the changes you said (.zip updated in attachment).
 
the behavior is the same. Maybe, i forgot something in the Configuration Bits or in setting of I/O.
 
 
 
#3
LdB_ECM
Super Member
  • Total Posts : 214
  • Reward points : 0
  • Joined: 2019/04/16 22:01:25
  • Location: 0
  • Status: offline
Re: PIC24FJ64GA102 : I/O pins not working as i would to drive an actuator 2020/01/13 03:47:18 (permalink)
0
You forgot to set the pins as output
 

   // Signal Verin_Sens : output
    _TRISB2 = 0;
    _RB2 = 1;
    _LATB2 = 0; // inital value 0
 
   // Signal Verin_ON : output
    _TRISB11 = 0;
    _RB11 = 1;
    _LATB11 = 1; // initial value 1

 
Set them in order tri-state buffer, output mode, set the initial value
post edited by LdB_ECM - 2020/01/13 03:50:14
#4
nrobin
New Member
  • Total Posts : 11
  • Reward points : 0
  • Joined: 2019/11/21 04:03:23
  • Location: 0
  • Status: offline
Re: PIC24FJ64GA102 : I/O pins not working as i would to drive an actuator 2020/01/13 08:02:08 (permalink)
0
Ok. I added the tri-state buffer before output mode. No changes are noticed.
 
Thank you for the advice.
#5
Jump to:
© 2020 APG vNext Commercial Version 4.5