Forum Replies Created
-
AuthorPosts
-
Ligo GeorgeKeymaster
Hi,
About PULL UP or PULL DOWN resistors used along with Switches.
Switch is connected to an input pin of Microcontroller. A pin is in input state means that it is in HIGH IMPEDANCE state. So if you don’t connect any PULL UP or PULL DOWN resistors that pin will remains FLOATING when the switch is in OFF state. A floating pin may catch noises and reading such a pin will result in unexpected results. Its value usually varies erratically varies.
Programming Language
It is C.
Ligo GeorgeKeymasterPlease post the code here.. otherwise it is not possible to find the problem.
Basically it will be a problem with function calling…
Ligo GeorgeKeymasterYou can make a pin of Microcontroller in High Impedance State by making it as an Input Pin. All input pins will be in High Impedance State.
Ligo GeorgeKeymasterYou can easily make an IO pin of PIC Microcontroller in High Impedance by making it an Input Pin. Just set the TRIS bit corresponding to the pin, it will make that pin High Impedance Input.
Ligo GeorgeKeymasterIt is very difficult to obtain accurate variable microsecond delay function. Make the oscillator clock frequency as high as possible and you can use Delay_Cyc() in MikroC which creates delay based in clock cycle. You may also try creating your own delay function like the following (following code is not calibrated for microsecond).
void Delay(unsigned int i) { for(;i>0;i--) { } }
Ligo GeorgeKeymasterTry like this :
switch(angle) { case 0 : PORTX.FX = 1; Delay_us(...); PORTX.FX = 0; Delay_us(...); break; case 1: PORTX.FX = 1; Delay_us(...); PORTX.FX = 0; Delay_us(...); break; }
Ligo GeorgeKeymasterMicro second variable delays will be very difficult to create and it will not accurate too as each instructions will take a few microsecond to execute. That is why MikroC doesn’t implement this function.
April 5, 2015 at 11:27 am in reply to: PIC 16F877A microcontroller and mpu 6050 3 axis Accelerometer & Gyroscope #11151Ligo GeorgeKeymasterMCP6050 is a 3.3V device while 16F877A is 5V.
So the best method is to use a Bi-directional logic level converter to connect both devices via I2C.
But I hope that it will work fine with 3.3V PULL UP resistors between them for testing / hoppy project purposes.
Ligo GeorgeKeymasterWhat is the problem with your project ?
Ligo GeorgeKeymasterIt is to convert each extracted digit to corresponding character.
‘0’ => 0 + 48
‘1’ => 1 + 48
‘2’ => 2 + 48
etc.Please refer ASCII Table for more reference.
Ligo GeorgeKeymasterUsing Interrupt with PIC Microcontroller – MikroC
Please read the datasheet of PIC 16F877A microcontroller… there you can find the procedure to use timer / counter module.
Ligo GeorgeKeymasterYou can program like this :
............. ............. TRISD.F0 = 1; TRISD.F1 = 1; ............. ............. while(1) { while(PORTD.F0 == 0) { LATB.F0 = 1; // Use LAT register to write output in 18F Delay_ms(1000); LATB.F0 = 0; Delay_ms(2000); } while(PORTD.F1 == 0) { LATB.F0 = 1; Delay_ms(2500); LATB.F0 = 0; Delay_ms(5000); } }
Ligo GeorgeKeymasterYou should check whether the data is ready or not… every time before calling UART_Read().
Ligo GeorgeKeymasterHello, you can use the INTERRUPT or COUNTER module of PIC Microcontroller for that.
Ligo GeorgeKeymasterNot, ECHO mode..
You should turn on NEW Message Indications by using correct settings
- AT+CMGF=1 – Text Mode
- AT+CNMI=2,0,0,0,0
-
AuthorPosts