From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-24-2011 10:06 AM - edited 06-24-2011 10:07 AM
I'm a bit confused
@neomus wrote:
Dear Coq
Yes the PIC is sending 10 bit ADC resolution by two bytes. I am getting the values and it displays properly on the LV as you will see from the previously attached VI. Now my problem is writing to serial port. I want to write 8 bit variable data to serial port. PIC will read this value and do the variable task.
Please advise me.
Reggards
Ananth
I'm a bit confused from your postings. Are you having trouble sending data to the PIC or sending data from the PIC. You seem to contradict yourself, in that you state the 10 bit ADC value is received by LV but you can't send data to the PIC from LV. But you also state that your LEDs are working after receiving data from LV (Or are you referring to the LED on yoru fp?). Please explain clearly what the issue is and what you are trying to accomplish so we aren't running around in circles.
06-24-2011 10:52 AM
i have problem with sending data from LV to PIC. Sending data from PIC to Labview is OK (ADC value). One LED is connected at PortA.3 of PIC. when i send "a" the LED should be ON and when i send "b" the LED should be OFF. My PIC is not receiving anything from LV. Source code in MIKROC is below. I have tested this code with C# and it is working.
Please advise me
// LCD module connections sbit LCD_RS at RB4_bit; sbit LCD_EN at RB5_bit; sbit LCD_D4 at RB0_bit; sbit LCD_D5 at RB1_bit; sbit LCD_D6 at RB2_bit; sbit LCD_D7 at RB3_bit; sbit LCD_RS_Direction at TRISB4_bit; sbit LCD_EN_Direction at TRISB5_bit; sbit LCD_D4_Direction at TRISB0_bit; sbit LCD_D5_Direction at TRISB1_bit; sbit LCD_D6_Direction at TRISB2_bit; sbit LCD_D7_Direction at TRISB3_bit; // End LCD module connections # include "built_in.h" unsigned char uart_rd; unsigned char ch; // unsigned int adc_rd; // Declare variables unsigned int tmp1; unsigned int tmp2; char *text; // long tlong; // void main() { INTCON.F7 = 0; //Global interrupt Disabled INTCON2.F7 = 1; //portB Pullup resistor disabled RCSTA.F7 = 1; // USART Enabled CMCON = 0x07; //Comparator OFF ADCON0.F0 = 1; //ADC Module Enabled ADCON0.F5 = 0, ADCON0.F4 = 0, ADCON0.F3 = 1, ADCON0.F2 = 0; //ADC(2) Enabled ADCON1 = 0x0C; //Analog channel A0,A1,A2 Read as analog input TRISA =0x07; PORTA.F3 =0; Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1,6,"LABVIEW"); delay_ms(1000); Lcd_Cmd(_LCD_CLEAR); UART1_Init(9600); delay_ms(100); while(1) { if (UART1_Data_Ready()) { uart_rd = UART1_Read(); if (uart_rd == 'a') { Lcd_Out(1,6,"ON "); // Write text in first row PORTA.F3 =1; } if (uart_rd == 'b') { Lcd_Out(1,6,"OFF"); // Write text in first row PORTA.F3 =0; } } adc_rd = ADC_Read(2); // A/D conversion. Pin RA2 is an input. tlong = (long)adc_rd * 5000; // Convert the result in millivolts tlong = tlong / 1024; // 0..1023 -> 0-5000mV ch = tlong / 1000; // Extract volts (thousands of millivolts) // from result Lcd_Chr(2,9,48+ch); // Write result in ASCII format Lcd_Chr_CP('.'); ch = (tlong / 1000) % 10; // Extract thousands of millivolts Lcd_Chr_CP(48+ch); ch = (tlong / 100) % 10; // Extract hundreds of millivolts Lcd_Chr_CP(48+ch); // Write result in ASCII format ch = (tlong / 10) % 10; // Extract tens of millivolts Lcd_Chr_CP(48+ch); // Write result in ASCII format ch = tlong % 10; // Extract digits for millivolts Lcd_Chr_CP(48+ch); // Write result in ASCII format Lcd_Chr_CP('V'); Delay_ms(1); tmp1 = Lo(adc_rd); tmp2 = Hi(adc_rd); if (UART1_Tx_Idle() == 1) { Lcd_Out(1,1,"byt1"); UART1_Write(tmp1); } delay_ms(10); if (UART1_Tx_Idle() == 1) { Lcd_Out(1,1,"byt2"); UART1_Write(tmp2); } delay_ms(100); } }
Regards
Ananth
06-24-2011 12:03 PM
Hi
Please find the simple read & write VI. I am getting the ADC value from PIC and it displays on LV. If i want to write any value from LV to port i use the boolean in the VI and control the LED connected to PIC. the problem is if i write any value to the port the PIC is not receiving it. Please advise me where i am making mistake.
Regards
Ananth
06-24-2011 12:56 PM
Have you tried using HyperTerminal to send the data? Try it. If it still doesn't work, the problem is not with LV, but with your programming or hardware setup. Have you scoped the signal to the PIC? I don't see any reason why LV should not be sending out data.
06-24-2011 01:04 PM
Yes i have tried with hyper terminal. When i send the variable data through hyper terminal PIC is receiving the value and doing the task. did you check the last VI i have posted. Is the code okay?. Also i have added a delay in the write and still having the problem. please check the attached VI with delay.
Regards
Ananth
06-24-2011 01:12 PM
Could it be you lack a control character such as CRLF (0x0D0A) to terminate your string? I don't know anything about your PIC, but it's worth a mention. I assume you scoped the signal with LV also? What did you receive?
03-22-2015 06:09 AM
Hi neomus
I am trying to do something similar I am only interested in reading values from the pic microcontroller could you please send me your vi saved as labview 8.5 as my labview version is 8.5.
This will be very generous of your.
Cheers Ihab
03-23-2015 04:19 PM
The problem with trying to talk with a microcontroller is that whoever programs the microcontroller will likely dictate the message protocol. You should have a nice long discussion with whoever wrote the code for your pic. But in general, the Simple Serial Read Write example is a decent starting point.
02-23-2017 04:02 AM
hello
greetings by balzzz
I need a help from you. i am having a particular data in my PIC 16F877A micro controller could you guide me in such a way that i could able to monitor the data in labVIEW
my mail ID is : balakumar.p11@gmail.com
contact me @ 9809425083
02-23-2017 04:20 AM
@balzzzNI wrote:
hello
greetings by balzzz
I need a help from you. i am having a particular data in my PIC 16F877A micro controller could you guide me in such a way that i could able to monitor the data in labVIEW
my mail ID is : balakumar.p11@gmail.com
@contact me @ 9809425083
Do you have the microcontroller code? Can you edit it? If so, you have the best chance. You will need to configure the UART and make some comms protocol for receiving commands and returning data.
You will then need some kind of line driver/level shifter for the UART comms. A max233 ciruit is easy and is sufficient for standard serial.
How easy this all is depends on your level of expertise. Just thank your lucky stars that most micros have UARTs now, coding them yourself in ASM is not so much fun.
A trick I quite often like to do is to tie one of the unused serial lines to the microcontroller reset line, so I can remotely trigger a reset by toggling a line in LabVIEW.