Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

single data type sending through serial port

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
omid_juve

Bascom Member



Joined: 30 Dec 2005
Posts: 55

blank.gif
PostPosted: Sat May 28, 2011 6:57 am    Post subject: single data type sending through serial port Reply with quote

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
View user's profile
six1

Bascom Expert



Joined: 27 Feb 2009
Posts: 553

germany.gif
PostPosted: Sat May 28, 2011 8:15 am    Post subject: Reply with quote

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
View user's profile
omid_juve

Bascom Member



Joined: 30 Dec 2005
Posts: 55

blank.gif
PostPosted: Sat May 28, 2011 11:21 am    Post subject: Reply with quote

how can i get this string in another micro?(if i use fusing)
what instruction should i use?
Back to top
View user's profile
PaulC

Bascom Member



Joined: 09 Jan 2008
Posts: 122
Location: Ireland

ireland.gif
PostPosted: Sat May 28, 2011 12:38 pm    Post subject: Reply with quote

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
View user's profile
Visovian

Bascom Member



Joined: 31 Oct 2007
Posts: 584
Location: Czech

czechrepublic.gif
PostPosted: Sat May 28, 2011 4:26 pm    Post subject: Reply with quote

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
View user's profile
mattcro

Bascom Member



Joined: 03 Oct 2007
Posts: 327
Location: Scotland

uk.gif
PostPosted: Sat May 28, 2011 4:54 pm    Post subject: Reply with quote

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
View user's profile
hgrueneis

Bascom Member



Joined: 04 Apr 2009
Posts: 902
Location: A-4786 Brunnenthal

austria.gif
PostPosted: Sat May 28, 2011 6:12 pm    Post subject: Reply with quote

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
View user's profile
amirf

Bascom Member



Joined: 25 Aug 2009
Posts: 154

indonesia.gif
PostPosted: Mon May 30, 2011 5:30 am    Post subject: Reply with quote

splite into byte , both variable in receiving and transmitting side , IMHO
Back to top
View user's profile
omid_juve

Bascom Member



Joined: 30 Dec 2005
Posts: 55

blank.gif
PostPosted: Tue May 31, 2011 8:30 pm    Post subject: Reply with quote

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
View user's profile
omid_juve

Bascom Member



Joined: 30 Dec 2005
Posts: 55

blank.gif
PostPosted: Wed Jun 01, 2011 3:03 pm    Post subject: Reply with quote

please help me
Back to top
View user's profile
kimmi

Moderator



Joined: 24 Feb 2006
Posts: 1922
Location: Denmark

denmark.gif
PostPosted: Wed Jun 01, 2011 3:38 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum