Forum Replies Created
-
AuthorPosts
-
RenParticipant
Well I get what you are saying but it still doesnt work. Hmm does the Vss pin need to be properly grounded?
RenParticipantWhy when I set any port as input and I write a condition for the output, I get the output regaurdless of thye condition, for the pic16f690. i.e
my code:
#include <htc.h>
#pragma config FOSC=INTRCIO
#pragma config WDTE=OFF
#pragma config PWRTE=OFF
#pragma config MCLRE=ON
#pragma config CP=OFF
#pragma config CPD=OFF
#pragma config BOREN=OFF
#pragma config IESO=OFF
#pragma config FCMEN=OFFvoid main(void)
{
ANSEL=0x00;
ANSELH=0x00;TRISBbits.TRISB4=1;
// TRISAbits.TRISA1=1;
// TRISAbits.TRISA2=1;
// TRISBbits.TRISB5=1;
TRISC=0;while (1){
if (PORTBbits.RB4=1)
(PORTC=0xff);
}
}I get Port c lighting up and no input triggered it.
RenParticipantWell Ajish thas for the help, but I got my decoder up and running, and my h-bridge and motor going, now is the hard part I’m trying to interface the pic16f690 (demo board chip ) to and 16×2 LCD to show the status of each device.
RenParticipantI’m using MPLAB IDE v8.88 and c18 compilier and I got an LED to light reading input by using a sample program on this site but, I have a major problem, before I can even sent 5V on portb to send it high, the LED on porte lights, matter of fact any wire, slight touch on any of the portb input pins causes it the LED on pote to light or stay on for a while, worst case it just comes on and stays on. The next problem is that, the porte output is about 2.5V max. From the looks of things I’m in deep trouble, here is the code.
//config.
#include <p18F4550.h>
#pragma config FOSC = INTOSC_EC
#pragma config PWRT = OFF
#pragma config BOR = OFF
#pragma config MCLRE = ON
#pragma config PBADEN = OFF
#pragma config ICPRT = OFF
#pragma config LVP = OFF
#pragma config WDT = OFF,DEBUG=OFFvoid main()
{
ADCON1=0x0F; // Set all pins as digital I/O
CMCON=0x07; // Set all comparators as digital I/O
TRISEbits.RE0=0; // Configure pin RE0 as output
TRISBbits.RB0=1; // Configure pin RB0 as input
while(1)
{
if(PORTBbits.RB0=1) // If input is high
LATEbits.LATE0=1; // Turn the LED On
else
LATEbits.LATE0=0; // Turn the LED Off
}
}RenParticipantI’m using momentary switches, specifically NO (Normally Open Switches) to send my signals of high to the input, to activate them. The problem I’m encountering is, how to send one signal, to turn the motor on, and keep it on, until another signal is sent to turn it off. My intension is to set up a device to feed the input ports BCD (Binary Coded Digit) to switch the devices on and off.
e.g, say 0001 = motor on
0010 = motor off
I have the LD293DNE chip, availble I think it should work for powering the motor.
Thanking you in advance.
-
AuthorPosts