![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| hi again guys, I'm facing another problem regarding on the Transmission of datas from my PIC to PC via the serial cable. Currently I'm using the RS232 model circuit taken accordingly from Nigel_goodwin's tutorial, a serial cable to connect to the PC (male to female converter) and of course the PIC to trasmit the data. I'm sending the data through RC6/tX. And my coding goes like this: __config _CP_OFF & _PWRTE_ON & _XT_OSC & _WDT_OFF ERRORLEVEL -302 ;Suppress bank warning org 0x000 goto start int org 0x004 goto int start CALL INITIAL START1 CALL SEND CALL CHECK GOTO START1 SEND MOVLW B'10010000' MOVWF TXREG RETURN INITIAL BCF STATUS,RP1 BSF STATUS,RP0 MOVLW B'00000000' MOVWF TRISB MOVLW h'24' MOVWF TXSTA MOVLW D'129' MOVWF SPBRG movlw B'10000000' movwf TRISC BCF STATUS,RP0 BSF RCSTA, SPEN RETURN CHECK MOVLW B'00010000' MOVWF PORTB ONEMORETIME BTFSS PIR1,TXIF GOTO ONEMORETIME MOVLW B'10000000' MOVWF PORTB RETURN END i'm actually relooping so that i'm constantly sending b'10010000' (90 in hexa). Since the start bit starts at the LSB therefore the data that is transmitting will be (startbit) 0 00001001 1 (stop bit) Am i sending a data '09' in hexa? i'm using a MATLAB program to receive these particular data and it doesn't seem to respond even though i send a data from my PIC. this particular data has gone through the rs232 for voltage conversion 12V and to the female serial cable which then goes into the male serial of the pc. When i measure the voltage out from the rs232.. it seems to be 20V.. not 12V. I'm trying out one of Nigel's tutorial regarding on the rs232 thingy but I don't really know what program to use to check weather or not the data which is being trasmitted from my PIC is being display on the PC. Is there any specific program to display the results i sent? hope you guys are able to give me some hint and help so that i know where to start. thanks in advance | |
| |
| | (permalink) |
| Use HyperTerminal on the PC, make sure you set it to the correct speed etc. and no handshaking. | |
| |
| | (permalink) |
| hi Nigel_Goodwin, i had already select the correct configuration baud rate 9600 data bits 8 stopbits 1 parity none flow control "hardware" for Hyper terminal, for normal situation we use none but still no sign of improvement.. the PC receives 12V.. but when it receives a 20v data.. surely it cannot read.. Is there any configuration needed for PIC to link with RS232 when sending data? isn't it the purpose of the Rs232 is to convert my signal data voltage into a voltage suitable for the PC to be received | |
| |
| | (permalink) |
| Hi Derrick826, Try to simulate first with this software http://www.oshonsoft.com/pic.html .It's good software, if its ok with simulator so its ok too with your real device. I always use this trick and working great. Thanks
__________________ http://www.henryelectronics.com | |
| |
| | (permalink) |
| yea thanks for the program i'm trying to figure out how to use it | |
| |
| | (permalink) | |
| Quote:
Also make sure you have TX and RX connected correctly, depending what type of lead you are using (either straight or crossover). | ||
| |
| | (permalink) | |
| Quote:
Your program will not run, number or errors. Tried in Oshonsoft, generates errors in hardware uart sim. Posted a simple uart program for you to try out, it works in Sim and PIC If you need any guidance using Oshonsoft, will be pleased to help.
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 7th July 2008 at 12:22 PM. | ||
| |
| | (permalink) |
| ok Nigel... i will try it out and let you know my progress.... thanks for your help. But i was little worried about my coding if it's incorrect. So far i'm able to simulate it. thanks for your help again! | |
| |
| | (permalink) |
| hi eric.. can you tell me briefly what does the ser1x.asm program do? I have tried my program in the Oshonsoft too using the both the hardware and software of uart sim... but there's nothing happening... what has gone wrong with my codings if i may ask? | |
| |
| | (permalink) | |
| Quote:
The program is set for 9600 baud, 1 start bit, no parity, 1 stop bit. It transmits "UART" and then <crlf> for a new line. then a 100mSec delay and repeats. In the Sim set the xtal for 4MHz, PIC as 16F877. Use the TOOLS menu to select 'hardware uart' Assemble the program using 'F9' keyboard key. Use Sim 'FILE' menu to LOAD the serx1.hex Start the simulation. Select 'Rate' as Ultimate
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ | ||
| |
| | (permalink) |
| hi, Screen shots of my settings. EDIT: added some notes for sim. Sequence: Start Sim Set PIC type Change Clock Frequency Tools/Hardware UART sim interface Tools/Assembler ... paste in serx1.asm to assembler Window From Assembler Menu/Tools/Assemble with MPASMWIN [ or 'F9'] .. wait for asm to finish From PIC Sim Menu/File/Load Program ... load the serx1.hex Menu/Rate/Ultimate [top speed] Menu/Simulation/Start NOTE: I usually shorten the LOOPMS delays to 0.1 before I assemble and load, else you could wait ages for a 100mSec delay in the Sim. Tip: From PIC/Sim Menu/Options/Change UART Transmit/Receive time...... SET to '50' For future ref when using LCD Module, From LCD Module Menu Click SetUp Click 'Setup LCD Module Busy delays' Change the '1640' default to about 100, you will get a faster update on the LCD. --------------- Extract from manual: use this to switch your delays On and Off So, just for the purpose of simulation you should recompile your programs with adjusted delay intervals, that should not exceed 1-10ms. But, be sure to recompile your program with original delays before you download it to a real device. There is an easy way to change arguments of all WAITMS statements in a large basic program with a value in the range 1-10 for simulation purposes. With one line of code setting parameter SIMULATION_WAITMS_VALUE with DEFINE directive, the arguments of all WAITMS statements in the program will be ignored and the specified value will be used instead during compiling. Setting the value 0 (default) for this parameter (or omitting the whole line) will cancel its effect and the compiled code will be ready again for the real hardware. ------------------------- DEFINE SIMULATION_WAITMS_VALUE = 1; delays ignored,,,, change to '1' before you program a PIC ! Hope this helps.
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 7th July 2008 at 12:22 PM. | |
| |
| | (permalink) |
| yea the hardware uart display UART..... but may i ask... in real life what's the 'hardware uart' does this hardware uart displays these alphabets? what if i were to transmit this character to the PC? this coding: MOVLW .13 ;crlf CALL TXRDY MOVLW .10 CALL TXRDY is similar to the other: MOVLW 'U' CALL TXRDY but why doesn't it displays the numbers? i'm sorry Eric... there's some coding here which i'm not really familiar with: LOOPMS MACRO MSEC MOVLW MSEC MOVWF WAITL CALL WAITLOOP ENDM ; ; ; ; LOOPMS .100 ;100mS delay after each line ; ; ; ; WAITLOOP: CALL DEL1MS DECFSZ WAITL,F GOTO WAITLOOP RETURN DEL1MS: ; 1ms delay loop MOVLW 0X64;100*10US=1MS MOVWF CNTR0 DL2: NOP NOP NOP NOP NOP NOP NOP DECFSZ CNTR0, F GOTO DL2 RETURN i'm not familiar with the LOOPMS MACRO MSEC the code : LOOPMS .100 (actually means that the LOOPMS having the value of 100?) and then the code : LOOPMS MACRO MSEC (means that the MSEC contain the value of 100 from LOOPMS?) so sorry Eric that you have to help me with this.. i'm kinda slow.. and i have ask a lot of nonsense... | |
| |
| | (permalink) | ||
| Quote:
Quote:
| |||
| |
| | (permalink) | |
| Quote:
Have a look at your other thread [ADC] just posted info.
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ | ||
| |
| | (permalink) |
| thanks guys! Eric.. if let's says in this case we are actually transmitting in ASCII characters. i have an ultrasonic circuit which displays a measurement value on the 7 segment LED , example 192 which my register: display_H = 00000001 display_T = 00001001 display_U = 00000010 has these 8-bit in binary is there anyway which i can do to trasmit this 8-bit binaries to allow the PC to display 192 on the screen? | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| Capturing serial data using PIC24 | nick2412 | Micro Controllers | 3 | 12th March 2007 10:32 PM |
| Need help badly on Inchworm and MPLAB | thushy | Micro Controllers | 14 | 11th March 2007 07:05 PM |
| Need some help with a code provided by ATMEL | ikalogic | Micro Controllers | 1 | 23rd January 2007 03:46 PM |
| Serial Data Logging Software | Monkeyman87 | Micro Controllers | 8 | 12th October 2004 04:32 PM |
| An error in pic16f84a, why? | Zener_Diode | Micro Controllers | 6 | 11th April 2004 03:55 AM |