LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pic 16f877 rs 232

Solved!
Go to solution

am i sendig ASCII code ????

0 Kudos
Message 31 of 39
(3,073 Views)

am i sendig ASCII code ????

0 Kudos
Message 32 of 39
(3,073 Views)

You will need to be more precise in your explanations and your terms, since I don't understand what you're talking about.

 

You said you want to "visualize portB from pic". You're already doing that with the chart. According to the pic code that you posted, the pic sends the value of port B over the serial port to the PC. If you want to see the values as LEDs, then use the Number to Boolean Array function as I already mentioned to convert the byte you read on the PC to an array of Boolean indicators. In the code the String to Byte Array is being used. If you replace this with a Type Cast function with a U8 wired to the type (as shown in previous examples), then you will get a single number out. 

 

You said " when i turn on some(8) switchs ,i can see the corresponding value on these led´s(8)!!". I have no idea what you're referring to. What switches, and what LEDs? Are these physical switches and physical LEDs that you're talking about?

 

You said 

 


i can recive data from pc!!
i just have a litle probleme.from pc i´m sending this data:

( recived)                            (send to portB)
    on pic                             from pc
0 00110000 -------------------0
1 00110001 -------------------1


OK, now I'm even more confused. According to the pic code you previously posted, the value that you are sending to the pic from the PC is being written to port D, not port B. Why is port B even involved in this part of it? I also have no idea what you're trying to tell us with those values. I'm guessing the first column is just a row number. What is the significance of the bit pattern 00110000? What does the 0 in the "send to portB" column mean?
0 Kudos
Message 33 of 39
(3,073 Views)

sory!!!

ok, i will tri to explain !!

 i´m sory about C programme , i´m triing things , and it is never the samme.i understend that is o lot of  confuse .

imagine a aquisition data bord.i have 8 input and 8 output.PORTB is output PORTD is intput.

i want to send data by 8 fisical  switchs (on/5v :off 0v ) conected tothe board.On labview a want to visualise it on 8 virtual led´s.

and i want to recive data from 8 virtual switch (on labview),to 8 fisical leds connected to the bord.

 

i have no probleme with sending data. the probleme is reciving it.

wen i send data ex:00000000--- i recive 00110000

                             00000001------------00110001
                             00000010------------00110010

                             ..........etc

 

                             00001010------------00110001---????? with numbers greater than 9, a have problemes.

and 0011xxxx bit 4 and 5  are alwais ``1´´?!?!.

am i sending to pic ascii code?????

0 Kudos
Message 34 of 39
(3,063 Views)

No, it is not sending the ASCII value. That tells me you have 2 stuck lines. In other words, a hardware problem, since those two bits are always on regardless of the value.

 

Also, please note the attached mod showing you how to replace all of your code with a simple Type Cast and Number to Boolean Array.

Message 35 of 39
(3,059 Views)

hooo  yes , i see that you are a pro on labview Smiley Wink

 

#include "built_in.h"


unsigned   i;

void main() {
USART_Init(9600); // Initalize USART (9600 baud rate, 1 stop bit, ...


TRISB = 0x00; // PORTA is output
TRISD = 0xff; // PORTA is intput

PORTB = 0;
PORTD = 0; 

do {

   USART_Write(PORTD); // Send lower 8 bits to UART

         Delay_ms(100);


       if (USART_Data_Ready()) {       // only do the following if data is received
          i = USART_Read();            // read the received data & assign to i
         // PORTB = i; ---------------- 
          PORTB = i-48;wen i use this (i-48) it dosent show that 2``1``--but a still have the same problemme.


          } // end if

   } while (1); // endless loop
} // end main

 

thanks again my friend for the good hellp !!

0 Kudos
Message 36 of 39
(3,056 Views)

Sorry, I made a goof. I had incorrectly used the Number to Decimal String function when creating the string to send. Replace the Number to Decimal String function in the last VI that I sent with a Type Cast function. You do not need to wire anything to the type input for that function in this instance since the default is to cast to a string. 

 

pic 16f877A Read_and_write_003_BD.png

 

When I said "No, it's not sending the ASCII code", I was replying to what I thought I had done, rather than what I had actually done. 

 

EDIT: I also noticed that in your latest pic code you swapped ports B and D as far as which is input and which is output. The labels of the Boolean arrays on the VI I sent you were based on the previous definitions.

Message Edited by smercurio_fc on 07-20-2009 05:16 PM
0 Kudos
Message 37 of 39
(3,045 Views)
Additional EDIT: There should also be a Reverse 1D Array function between the Number to Boolean Array and the array indicator. Otherwise the LEDs will light up in reverse order.
0 Kudos
Message 38 of 39
(3,039 Views)

I don''t think it's a hardware problem .. I'm having a similar problem .. I noticed when i change the byte count they ON bytes change as well

for example sending 0000 0001 

 

when byte count is 8, it gives an output of 0011 0001

 

when byte count is 7, it gives an output of 1011 0001

 

when byte count is 6, it gives an output of 1111 0001

 

I tried reseting the port on the microcontroller but i think it has something to do with the program !

0 Kudos
Message 39 of 39
(2,075 Views)