Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Please help me with my problem...T_T

Status
Not open for further replies.

nifleheim13

Junior Member level 1
Joined
Nov 19, 2010
Messages
17
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,409
I've look through the forums but i can't seem to find an answer for a beginner like me......i've been studying how to program PIC16F84A for my project.....i know some of the basics now but what i really need is to connect it to the rs232 port.....for example, i will send data from Visual Basic 'MsComm1.Output = Chr$(123)'.....the pin #3 of rs232 is connected to RA0 of PIC16F84A (or any I/O port), from here on i don't know what to do next.....i don't know how the pic accepts the data from the rs232 port....i've tried this and unluckily it doesn't work

movlw PORTA,0
movwf PORTB

i'm trying to make the 8 pins of PORTB connected to an LED lit using VB6.0.......i think that if i can't make a simple program like that then i can't make what i really need to do.....


**this is what the real process should be.....i'll just use again LEDs....

e9dgdx.jpg


*the PIC connected to the rs232 port is the master PIC
*the 4 PICs connected to the master PIC are the SLOT PICs (4 pic stands for 4 slots)
*the 4 LEDs connected to the master pic determines which slot is selected
*the LEDs connected to the slot PICs stands for ports (3 ports per slot)

****here's the process....

VB6.0 will send two values, the first value is for the slot number and the second value is the port number for the selected slot.....2 LEDs will lit, the first one is to determine which slot is selected and the second one is to determine which port....

is this possible with the PIC i selected?....i think it is...i just don't have the knowledge and it must be hard.....and if it isn't possible...what PIC would you recommend?

i hope you can help me....thanks.....^_^
 

Hi my friend... First of all, i would change the microcontroller your using and replace it with PIC16F628, because this one has the integrated peripheral, Universal Synchronous/Asynchronous Receiver/Transmitter USART/SCI and yours don't seem to have this. They are not expensive, actually both of them are old versions of the current 8 bit microcontrollers of microchip, but they can still handle many applications. you should also think about using the IC MAX232 as an interface between the PC and the master microcontroller, because it acts as a converter of RS232 levels to TTL levels. There other ways to acomplish that but i think it is the easier one. You can also use VB to make a simple program to access the RS232 port, i have done it a long time ago, but i if i can remember, there were some cases that i used windows API to access the serial port rather then using built in functions of VB, you have to look in internet for more information.
Good luck
 

to connect PIC with PC..u need to use serial comm(UART)..the pic that u use is dosnt have serial com..there is many sample for u in internet how to do connect PIC and PC using serial com..goto my website..i already settle down your problem..

thelocxresearch.tk

anyway, i draw this for u.. to simplify how to connect it..
 

Attachments

  • serial com.jpg
    serial com.jpg
    185.3 KB · Views: 135
Last edited:

Hi,
For RS232 you need to use UART, but 16F84A doesn't have UART. So your solutions are either:
1) Choose a PIC with UART module
2) Use software UART module

Since you're learning 16F84A, use it and use software UART.
Now, which language and compiler do you use?
In mikroC or mikroBASIC, there are functions for software UART. You can quite easily use that. eg. You have sent 128 through serial port, at 9600bps, you could do:
Code:
error = Soft_UART_Init(PORTA, 1, 0, 9600, 0) 'Initialize UART module, 9600bps, RX at RA0, TX at RA1, non-inverted
if error = 0 then 'No error
   val = Soft_UART_Read(error)
   if error = 0 'If data read successfully
      PORTB = val
   end if
end if

This is a sample code for use in mikroBASIC. I hope you understand it.

Hope this helps.
Tahmid.
 
@mago

pic8.gif

are pins 7 and 8 is what will i connect to the rs232 port for the recieved and transmitted datas?

if i change to pic16f628, how does the pic accept the data from the serial port (DB9)....could you give me a sample?

_______________________________________________________________________

@Tahmid

i'm using MPLAB IDE, Assembly Language and MPASMWIN compiler....but i could change it if needed.....i've been starting to look for C samples and C compilers too.....

about the software UART module....i look over the net but can't seem to find it......i'm not yet familiar to it, i'm not sure what to look for....T_T....could you show me where to get that....i'm sorry for being so dumb.....i'm really a complete beginner in this.....

is RX is for the recieved data and TX for the transmitted data?....about the process i've shown, is it possible?

________________________________________________________________
 
Last edited:

What you are totally missing is the difference of UART and RS232. The signal levels are not the same so therefore you need a converter between these signals. See the schematic from lockman_akim and you will see such a chip. There are of course a lot of different circuits but is is not important what you chose. Decide how many signals you need to transfer between the computer and the PIC and select the circuit that needs as few extra components as possible and is cheapest.
RX and TX is data. Connect the RX on the PIC side to the TX on the PC side. (Same for all signals but you maybe do not need any more).
RXD and CTS is used to stop data to let the reciever have time to take care of the previous byte. If you send very slow you don't need them and you can just short circuit them on the PC side. From PIC to PC this should not be a problem, the PC is fast and have buffers.
This should give you a start and what you need to do to understand more is to start reading the data sheets of the circuits.

Good luck.
 

Hi,
RX is short for receiver, TX for transmitter. Here TX is PC, RX is microcontroller. You need to search for Software UART or Software USART. If you're interested in C, use the mikroC library files. They're very similar to what I posted. Do one thing. Go to MikroElektronika - Development tools, Compilers, Books. In their forums search for "Soft_UART". You are likely to get some info. Search "Soft_UART" in google as well. I'll try to post a mikroC code.

Hope this helps.
Tahmid.
 

this is the circuit..what u need now is to understand about serial com..
serial com with pc is not the same with parallel com..
using parallel com u can easily do "ON and OFF"..
i gave u an example..

i want to light up the LED attach at PORT.B1, so what i need to do is, do some programming a PC (Using Visual Basic)..

*****************************************************
at vb , i program at "button" everytime i hit it, it will send value "100"..

(mscomm1.output = "100")
*****************************************************


******************************************************
then at PIC, i program it,

if receive value 100 then ON PORT.B1..

******************************************************

u said u want to use assembly, i dont know ASM, if u want BASIC or C..myb i can help..
 

Attachments

  • serial com.jpg
    serial com.jpg
    174 KB · Views: 130
Hi,
This is a sample code in mikroC:
Code:
Soft_UART_Init(PORTA, 1, 0, 9600, 0); //Initialize UART module, 9600bps, RX at RA0, TX at RA1, non-inverted
  do {
    do {
      data = Soft_Uart_Read(rec); // Receive data
    } while (!*rec);
    PORTB = data; //send to PORT
  } while (1);
}//~!

Hope this helps.
Tahmid.
 

@lockman_akim

it's alright if it's C or Basic...i have some knowledge about C too so it's fine....and BASIC...vb was derived from it right?...so i think it's alright too....

in the circuit you've shown me, was it necessary to use max232 or is it alright without it?

this is the schematic diagram of the burner/programmer that our professor gave us for pic16f84a, can i use it for pic16f628a too?

2501ija.jpg



i'll try using pic16f84a with the soft_uart and i'll also try changing to pic16f628 to see what best suits me....
 
Last edited:

Hi,
Since you can make do with C and BASIC and assuming you know VB, then, you should download mikroBASIC and try the code and implement it. You'll be done in a short while as it makes things quite easy.

Hope this helps.
Tahmid.
 

yup....i started downloading mikroC, mikroBasic and mikroPascal......i think i'll start testing mikroBasic cause i've been programming in vb for long......
 

Hi,
Goto help menu. There click "mikroBASIC PRO for PIC libraries" on the left hand side. Click Software UART library. This contains all details you need. As for hardware connections, click "mikroBASIC PRO for PIC libraries" on the left hand side, click UART library. Scroll down and there's the interface. You just need to change the TX and RX pins for those you specify in the Software UART library.

Hope this helps.
Tahmid.
 
that really helps a lot.....i will try as soon as possible.....it really is a good choice to ask in forums......thanks a lot....
 

@lockman_akim

it's alright if it's C or Basic...i have some knowledge about C too so it's fine....and BASIC...vb was derived from it right?...so i think it's alright too....

in the circuit you've shown me, was it necessary to use max232 or is it alright without it?

this is the schematic diagram of the burner/programmer that our professor gave us for pic16f84a, can i use it for pic16f628a too?


i'll try using pic16f84a with the soft_uart and i'll also try changing to pic16f628 to see what best suits me....

im not sure your burner can do it or not, but i think no.. the max232 is necessary..computer send signal with +15V and -15V while PIC is +5V and 0V..so the max232 change the computer signal to signal that PIC can receive..
 

Hi,
I think the burner can do it, just check if the software on your PC can support it.

Hope this helps.
Tahmid.
 

was it really necessary?....last year we made a simple robotic arm with servo motors.....we found this on the net and it worked.....the schematic diagram doesn't have a max232....i've tried to directly connect it like in the diagram but it doesn't work.....it was on setup then PIC16F84 schematic of the software.....i've uploaded the software...the link is below....

aw3kms.jpg


Link for the software
**broken link removed**
 
Last edited:

yes..you need the max232..else you can build your own level shifter using some transistor and resistor..but it is more recommended to use max232..
 

that is what i need.....i need to do it without the max232.....can you show me the level shifter circuit?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top