You are here: Home FORUM Support Using the SCI reader

nqBASIC

  :: Support
Welcome Guest   [Register]  [Login]
 Subject :Using the SCI reader.. 28-02-2011 10:34:34 
jctullos
Joined: 28-02-2011 15:32:29
Posts: 6
Location

I'm having problems with the SCI get char. For some reason it's not reading any thing from the serial port,

Is there another way in nqbasic to take a string from the RX and put it on an LCD? Because that way doesn't seem to work..

 

Thanks!

IP Logged
 Subject :Re:Using the SCI reader.. 28-02-2011 18:29:51 
carl
Joined: 27-05-2009 10:51:54
Posts: 17
Location: Toronto

Check out the calculator program (http://www.technologicalarts.ca/support/docs/nqBASIC/ProjectExamples/NanoCore12DX/calcnc12dxc32/) to see one example of using it.

Just for fun, I took elements of that example and combined them with elements of the LCD example program (http://www.technologicalarts.ca/support/docs/nqBASIC/ProjectExamples/NanoCore12DX/lcdnc12dxc32/) to come up with a working example that takes SCI characters and echoes them to both the SCI and to an LCD.  I've posted the project in the nqBASIC Support Library, here:
http://www.technologicalarts.ca/support/docs/nqBASIC/NewExamples/SCI2LCD/

Hopefully that will get you going in the right direction...

Carl

IP Logged
 Subject :Re:Using the SCI reader.. 28-02-2011 18:50:25 
jctullos
Joined: 28-02-2011 15:32:29
Posts: 6
Location

Oh that's awesome. Thanks for the help. Yeah I had found the calc example like right after I posted that. So I was able to use a lot to help get it going. It seems though that my numbers are just going through as ASCII chars. I'm guessing it's because of this line:

digits[position] = char - '0' //assemble the number using the ASCII digits received and store in array at position

So if I just want to store binary 1's and 0's then just using the plain:

S.SER_Get_char (0, char) //Get the character

Should be sufficient enough right? I've been able to get 2 Xbee modules to communicate so far through this program which is nice. In the end one xbee will send temp/humidity data through their ADC's to the nanocore. Thanks again for the help. NQbasic has been a huge help to take out a lot of the guesswork for when I was programming this stuff in assembly.

IP Logged
Last Edited On: 28-02-2011 18:51:27 By jctullos for the Reason editing
 Subject :Re:Using the SCI reader.. 28-02-2011 19:23:54 
carl
Joined: 27-05-2009 10:51:54
Posts: 17
Location: Toronto
Glad to hear it! Subtracting the ASCII value for '0' results in the numeric value, because the ASCII values for the characters '0' through '9' are 0x30 through 0x39 or 48 through 57 (decimal) So it depends on what format XBee is sending, and what you want to end up with-- ASCII or numeric. If you need to convert the received ADC value to real units (e.g. temperature in deg. C) than you'll need to convert it to a numeric value in order to do some math on it, and then display the result on the LCD using the appropriate LCD function.
IP Logged
 Subject :Re:Using the SCI reader.. 03-03-2011 05:04:11 
jctullos
Joined: 28-02-2011 15:32:29
Posts: 6
Location
Hey another question, I've got the ADC working and such with the temp sensor, is it displaying the 8 byte data in hex or something, or into ASCII? I don't think it's hex, because right now I've got it sending the data (without unit conversion) straight to the LCD, and its displaying 2 numbers. I know the temp sensor works because the value goes up when I touch the sensor (since I have it in a loop). The temp sensor sends the data back in mV to the ADC. It's definitely new to use this new nanocore12. I'm used to programming the 68hc11 in assembly, and being able to manipulate the data from an ADC in binary lol
IP Logged
 Subject :Re:Using the SCI reader.. 03-03-2011 05:04:14 
jctullos
Joined: 28-02-2011 15:32:29
Posts: 6
Location
Hey another question, I've got the ADC working and such with the temp sensor, is it displaying the 8 byte data in hex or something, or into ASCII? I don't think it's hex, because right now I've got it sending the data (without unit conversion) straight to the LCD, and its displaying 2 numbers. I know the temp sensor works because the value goes up when I touch the sensor (since I have it in a loop). The temp sensor sends the data back in mV to the ADC. It's definitely new to use this new nanocore12. I'm used to programming the 68hc11 in assembly, and being able to manipulate the data from an ADC in binary lol
IP Logged
 Subject :Re:Using the SCI reader.. 03-03-2011 16:47:43 
carl
Joined: 27-05-2009 10:51:54
Posts: 17
Location: Toronto
I believe the data stream coming from the XBee module is ASCII, so I'd guess you are displaying two ASCII characters. You'll need to convert those to decimal by subtracting the ASCII value of '0' from each, multiplying the most significant digit by 10, and adding the result together. Then you can do some math on them to convert to real temperature units, or just pass them to either the LCD_hex or LCD_decimal function for display on the LCD. By the way, which temperature sensor are you using?
IP Logged
 Subject :Re:Using the SCI reader.. 03-03-2011 17:55:49 
jctullos
Joined: 28-02-2011 15:32:29
Posts: 6
Location
Well the thing is I haven't connected the temp sensor to the xbee yet. I wanted to make sure everything was working properly before I connected it to the xbee, so right now it's hooked straight up to the ADC. So that's why I was confused that it was displaying in ascii for some reason. And the temp sensor is the TMP36.
IP Logged
 Subject :Re:Using the SCI reader.. 03-03-2011 18:13:47 
carl
Joined: 27-05-2009 10:51:54
Posts: 17
Location: Toronto
The question is: which LCD function are you using to display the reading: LCD-char? LCD_decimal? or LCD_hex? The value returned by the ADC_read function is 8-bit or 16-bit (depending on how you DIM it), and it will be interpreted in different ways depending on which LCD function you pass it to.
IP Logged
 Subject :Re:Using the SCI reader.. 10-03-2011 06:32:30 
jctullos
Joined: 28-02-2011 15:32:29
Posts: 6
Location
Well so far things are coming along. The one thing that would be helpful, is there a way (hopefully easy) to do floating point calculations with nqbasic? I couldn't find it anywhere in the documentation!
IP Logged
 Subject :Re:Using the SCI reader.. 14-03-2011 06:29:13 
carl
Joined: 27-05-2009 10:51:54
Posts: 17
Location: Toronto
Floating Point is not implemented in nqBASIC. If you really need FP though, there is a cool co-processor chip that you can use: http://www.micromegacorp.com/umfpu-v2.html
IP Logged
Page # 


Powered by ccBoard