Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 10, 2016, 04:00:54 04:00


Login with username, password and session length


Pages: [1]
Print
Author Topic: MikroBasic for Pic USART and variables help please  (Read 1381 times)
0 Members and 1 Guest are viewing this topic.
ffr58kk90
Junior Member
**
Offline Offline

Posts: 39

Thank You
-Given: 29
-Receive: 0


« on: April 27, 2014, 03:55:43 15:55 »

Hi

I have been struggling along trying out MikroBasic Pro for PIC, i've connected the pic, a 16f876 via a max232 to the RS232 port on my pc, I can send characters from the pc, they get echoed back using the sample MikroBasic code from the manual.

What I am trying to achieve is to send out a series of digits from the PC serial port and save them in the pic as a floating point variable so I can do some maths on them.

For example, from the PC I type 12.34567, how do I save this as a float variable?, I have tried using uart1_read_text, and saving the value as a text string, but there is no function to convert this to a float, I can send it back to the pc so I know it has been received correctly.

I can also save the incoming data character by character and store it in a byte array, but how then can I make this into a float variable?

I am totally stumped, can anyone help please,


Thanks

Regards
Ffr.
Logged
micropcb
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 29
-Receive: 150


« Reply #1 on: April 28, 2014, 09:07:41 09:07 »

If you were using C on the PIC side, may be you could declare a float variable and then do
variable = 10*(byte in 10's place) + byte in 1's place + 0.1 * (byte in 1st place after decimal point) +  0.01 * (byte in 2nd place after decimal point) and so on....

Just my bit. You have to try that to see if it works in MicroBasic.

Best regards.
« Last Edit: April 28, 2014, 09:10:06 09:10 by micropcb » Logged
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2018

Thank You
-Given: 514
-Receive: 477


Top Topic Starter


« Reply #2 on: April 28, 2014, 10:39:47 10:39 »

use sth like this: "dim x as float absolute 0x32" in your PIC, and you will be able to access individual bytes.

rs232 is 8-bit transmission system.

on your PC, you can get the address of your float variable and do the same thing.

Usually, people do it the other way around, they send text to PC from PIC, you want to do the other way around, you need to do extra work.



Logged

nothing to say..
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC