Actually not quite six... hmmm... I hope I still look like my picture in 14 years time...you've been a design engineer for what; 20 years?
Actually not quite six... hmmm... I hope I still look like my picture in 14 years time...you've been a design engineer for what; 20 years?
I don't understand the ironic attitude. Did not the answer #2, #4, #8 really helped you solve the problem at the utmost polite way? Ohh, people...
I think you will look great even after 30 years! Engineers are doing proper service's at the set intervals!
Ioannis
Hi Mr.Ioannis,
Actually i really very thankful and appreciate the solution that u given to me. I also not meant that u dint help me but i just scared that i was disturbing you. Now i still try to troubleshooting for the code and my hardware. Hopefully it can be working one day.
Thank you very much
Project instructions:
1. Read the Data Sheet.
2. Read the PIC Basic manual.
3. Read this forum.
4. Use FIRE extinguisher.
5. Post question stating:
A. Every thing you tried
B. Post Your CODE.
C. Post schematic if applicable.
Back to the topic....
What problems are you still having?
Dave
Always wear safety glasses while programming.
Hi Dave,
1. The attachment is my circuit diagram, pls comment to me if there are something wrong.
Thanks
2. Source Code:
'################################################# #########
Define OSC 10
include "Modedefs.bas"
ADCON1 = 7
TRISA = %010000 'RA4 as serial input, RA3 as serial output
TRISB = 0 'PortB used to ON the LED
CHAR var byte
PORTB = 0
Main:
SERIN PORTA.3,T9600,CHAR
PORTB = CHAR
SEROUT PORTA.3,T9600,[CHAR,10] 'I used hyperterminal to received the data
'that sent to pic
GOTO MAIN
############################################
3. I was try to change the value of OSC but still get the same result. For Example: when i sent "1" from hyperterminal to pic but the result that returned to hyperterminal is " ' " then the result on LED is "11111010". I was checked the ASCII table, the result is not same with the data i sent.
Hi guys,
I'm a new guy where pics are concern, but i'm more experienced with my other hobbys.
Since i dont have anyone that i can learn with i have to teach my self and learn with my mistakes and experiments.
For each hobby i have i also participate in the related forums.
I try to share my experience and try to give my knowledge with the new guys as i remember myself some time before asking for it or came across a dead end as the new guys do now.
Sure for me can be obvious some issue but it can be a hard step for a new guy to go through.
And i know how fustrating can be when hitting a dead end and not having a little help to get arround it. I know some people that leave their hobbys for that.
This is the point of the foruns. For people to share information and experiences. To help the other guy regardless of the question.
Me for example i use datasheet but because i'm a new guy in pic world there are many thing i dont undestand in them !
I've been helped many times here and i believe that if it wasnt for the guys here i wouldnt be able to continue with my learning curve and getting stuck with a flat line !
Sorry for the long post...just wanted to share my humble opinion
.
The first thing that I see is you have SERIN and SEROUT on the same pin.
I have never tried A4 for serialCode:SERIN PORTA.3, SEROUT PORTA.3,
http://www.picbasic.co.uk/forum/showthread.php?t=562
You may have to use another pin.
Right now do not worry about TRISA. The SERIN/SEROUT takes care of that.
Dave
Always wear safety glasses while programming.
If you just want the short answer.....
I think you may have made a misstake with the pins
PORTA.3 is Data PIC>>>>PC (serout in pbp)
PORTA.4 is Data PC>>>>PIC (serin in pbp)
using PORTA.4 as an input is not a problem at all, if you want to use it as output you need a pull-up resistor to make it work.
Change is your sw and it might work better.
If you want a longer answer......
Yes datasheet can be really strange to read and understand, this we all have to accept. Training and experience will make it easier and even simple. This is fact.
Now to a different thing, making electronics with PIC inside is not that different from sport, training makes a difference and not all people have the same skills. It is easy to wish for a cool electronic gadget but much harder to make it. I am not writing this to put someone down, no I am writing this to explain how to get there and that is One Small Step at the Time. Don't expect to write a missileguiding SW the first day but eventually you will.
So I want to make a thing that can turn on and off LED from a PC, how would I do that?
A, Make a plan, with a good plan you will save much time later. Figure out what you want the circuit to do and what hardware you will need. You can always make the plan better later but you honestly need a plan before you start.
B, Test the hardware. Here is the best thing the undervalued Flash a LED program most usefull. Time spent verifying the hardware you will get back 1000 times later because when you see strange things you can rule out HW problems. If you can't flash a led you can not expect anything else to work ever....
C, If you want to connect to a PC do not start with a SERIN problem. Start with a SEROUT so you can see that you can send data to the PC. Even if you will not use it later?? YES!! Because it is easier to recieve data with a PC compared with a PIC, if you can send data to the PC it is more likely that the other way is working also. I almost always include a line early in the program to send SEROUT......... " PIC STARTED " so when I see this is hyperterminal I understand that the PIC is happy. It is also a great way of troubleshooting later because you can always send serial data to the PC to display arrays and other variables. When you can see the data on the PC you have proof that Baud and Mode are correct and you also know you are using the correct serial port on the PC.
D, Make sure you know where the PIC is in your progam before you do a Serin. Like other people said before use a start char to start the Serin function for example ":" or "X" or any other you want to use, just make sure you use one.... so do a serout first in your code
Serout............"PIC waiting for data" followed by a SERIN ........... that has a start char. Now you are sure that the PIC is waiting for char from the PC, now use the PC to send 2 char (start char + data char). After the Serin line I would put a new Serout line that has Serout.......... "Data recieved",#Data_Char Now I can see that the PIC moved forward in the program and what data was recieved. Please remember that ASCII and dec numbers can be confusing so double check or force the data to be in DEC fromat using the # function. IF you are not using a start char you are not sure that the data char is correct, serin will take any data and you will be in the land of trouble.
This is one small step at the time, the key to R&D and the best way to make progress. Later when you have everything working you can remove lines in the code that you are not using and the code becomes smaller and cleaner.
The good thing with PIC is that they are small computers, they do exactly what you tell them, the bad thing with them is they are small computers, they do exactly what you tell them.You can not expect the PIC to be forgiving in anyway, there are no help files incuded just the data sheet written by nerds for nerds.
To make the a circuit that turns on a LED is a very good project but it is not a simple project, it will take time, skill and patience but eventually you will get it to work.
Define OSC 10
include "Modedefs.bas"
ADCON1 = 7
TRISA = %010000 'RA4 as serial input, RA3 as serial output
TRISB = 0 'PortB used to ON the LED
CHAR var byte
PORTA.3=1
PORTB = 0
SEROUT PORTA.3,T9600,[" PIC started",10,13] 'I used hyperterminal to received the data
GOTO MAIN
PC_IN:
SEROUT PORTA.3,T9600,["Use : as start char",10,13] ' write :A in hyperteminal...
SERIN PORTA.4,T9600,[":"],CHAR
SEROUT PORTA.3,T9600,["Data from PC ",CHAR,10,13] '
RETURN
Main:
GOSUB PC_IN
GOTO MAIN
GOTO MAIN
Bookmarks