Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
March 29, 2024, 06:01:19 06:01


Login with username, password and session length


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

Posts: 40

Thank You
-Given: 116
-Receive: 0


« on: April 27, 2014, 02:55:43 14: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
Active Member
***
 Muted
Offline Offline

Posts: 113

Thank You
-Given: 53
-Receive: 390


« Reply #1 on: April 28, 2014, 08:07:41 08: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, 08:10:06 08:10 by micropcb » Logged
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2420

Thank You
-Given: 862
-Receive: 678


Top Topic Starter


« Reply #2 on: April 28, 2014, 09:39:47 09: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
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