View previous topic :: View next topic |
Author |
Message |
omid_juve
Joined: 30 Dec 2005 Posts: 55
|
Posted: Sat May 28, 2011 6:57 am Post subject: single data type sending through serial port |
|
|
i have 4 single data type . i want to send it through serial port .
how can i do this ? (i mean with what instruction should i use to send and receive it ?) |
|
Back to top |
|
|
six1
Joined: 27 Feb 2009 Posts: 553
|
Posted: Sat May 28, 2011 8:15 am Post subject: |
|
|
there are several way's...
easiest is to send it as string.
Have a look at FUSING in Bascom Helpfile... _________________ For technical reasons, the signature is on the back of this message. |
|
Back to top |
|
|
omid_juve
Joined: 30 Dec 2005 Posts: 55
|
Posted: Sat May 28, 2011 11:21 am Post subject: |
|
|
how can i get this string in another micro?(if i use fusing)
what instruction should i use? |
|
Back to top |
|
|
PaulC
Joined: 09 Jan 2008 Posts: 122 Location: Ireland
|
Posted: Sat May 28, 2011 12:38 pm Post subject: |
|
|
maybe you could store them in eeprom and send bytes across to other micro and then restore the bytes sent to ready made variables i.e. 2 for word lower and upper ending in 00 and 1 for byte ending in 00, and so on.. _________________ Bascom Avr 2.0.7.3
Works for me
|
|
Back to top |
|
|
Visovian
Joined: 31 Oct 2007 Posts: 584 Location: Czech
|
Posted: Sat May 28, 2011 4:26 pm Post subject: |
|
|
On the receive side use
Code: | Dim Str1 As String * 10
Dim Var1 As Single
Input Str1
Var1 = Val(str1) | The transmitted value is in Var1. |
|
Back to top |
|
|
mattcro
Joined: 03 Oct 2007 Posts: 327 Location: Scotland
|
Posted: Sat May 28, 2011 4:54 pm Post subject: |
|
|
You could also try PRINTBIN and INPUTBIN. I haven't tried this but guess it should work. _________________ If all else fails, read the manual. Even better: read the manual before something fails. If you can't find it in the manual, search the forum.
BascomAVR 2.0.8.5 |
|
Back to top |
|
|
hgrueneis
Joined: 04 Apr 2009 Posts: 902 Location: A-4786 Brunnenthal
|
Posted: Sat May 28, 2011 6:12 pm Post subject: |
|
|
mattcro is right, use PRINTBIN and INPUTBIN. It works.
Just DIM the receiving variables the same type as the transmitting variables.
I usually use a leading marker-character (that is not used otherwise) for a start and variable marking and wait for that, so the receiver knows which variable to store the data to. Useful for changing sequences of transmission.
The transmissions have to be the type of variables you use at the receiver, otherwise you collect garbage because it waits for the exact number of bytes that are contained in a certain variable type. See HELP file.
Hubert |
|
Back to top |
|
|
amirf
Joined: 25 Aug 2009 Posts: 154
|
Posted: Mon May 30, 2011 5:30 am Post subject: |
|
|
splite into byte , both variable in receiving and transmitting side , IMHO |
|
Back to top |
|
|
omid_juve
Joined: 30 Dec 2005 Posts: 55
|
Posted: Tue May 31, 2011 8:30 pm Post subject: |
|
|
i am connecting two micro using txd rxd pin . i use below program for communicating between these two micro . but when i run it in proteus
just i have this at the screen of the lcd " -nan" . could you plz help me what my problem is ?
transmitter side
Serialcheck Alias Pinb.0
Dim W6 As Single
W6 = -123.4
Do
If Serialcheck = 0 Then
Waitus 100
Printbin w6
Waitms 30
End If
Loop
End
receiver side:
dim w14 as single
Do
If Adcupdate = 0 Then 'the "adcupdate" is a pushbutton key'
Reset Serialcheck
Inputbin W14
Lcd W14
Set Serialcheck
Wait 1
End If
Loop |
|
Back to top |
|
|
omid_juve
Joined: 30 Dec 2005 Posts: 55
|
Posted: Wed Jun 01, 2011 3:03 pm Post subject: |
|
|
please help me |
|
Back to top |
|
|
kimmi
Joined: 24 Feb 2006 Posts: 1922 Location: Denmark
|
Posted: Wed Jun 01, 2011 3:38 pm Post subject: |
|
|
Hi
I tested this setup and that works ok (even in Proteus)
Code: | ' TX
$regfile = "m16def.dat"
$crystal = 8000000
$hwstack = 32
$swstack = 20
$framesize = 40
$baud = 9600
Dim W6 As Single
W6 = -123.4
Do
Waitms 400
Incr W6 ' just as test for diffrent value on RX LCD show
Printbin W6
Loop
End
' RX
$regfile = "m16def.dat"
$crystal = 8000000
$hwstack = 32
$swstack = 20
$framesize = 40
$baud = 9600
Config Lcdpin = Pin , Rs = Portb.2 , E = Portb.3 , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7
Config Lcd = 16 * 2
Cursor Off Noblink
Cls
Dim W6 As Single
Do
Inputbin W6
Cls
Lcd Fusing(w6 , "00.000")
Loop
End |
_________________ / Kim |
|
Back to top |
|
|
|