BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 12:16 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: HSERIN/HSEROUT differences between Nano-18/Nano-40?
PostPosted: Fri Oct 14, 2011 2:30 pm 
Offline
Guru

Joined: Sun Jan 03, 2010 8:01 am
Posts: 55
Location: Eau Claire, WI
Greetings all,

I have wrote a program which uses the HSERIN/HSEROUT commands to communicate with a rather touchy serial-based LCD display. The issue that I am running into now is that the program I have developed only works on the Nano-40; when I use the program on a Nano-18 either nothing is displayed or an single "A" is displayed.

I know that from the manual that there is a differences for hardware pins which I have made adjustments for; I am left wondering if there are some issues between the Nano-40 vs. the Nano-18 that are not listed in the manual. I have include the major part of my code for others to review. Thanks for any insight that anyone can offer.

; ********************************************************************************
; ** Thermostat Control Program
; **
; ** Processor: Basicmicro Nano-18
; ** Temperature Sensor/Floor: LM34CAZ
; ** Temperature Sensor/Air:
; ** LCD Display: 4D Systems
; ** Wireless Interface: XBee Series 1
; **
; **
; **
; ** LCD Display Connections to the Nano-18
; ** Reset: Pin-16 of Nano-18 (P13-General Purpose Pin)
; ** TX: Pin-8 of the Nano-18 (P2-AUSART RX Pin)
; ** RX: Pin-11 of the Nano-18 (P5-AUSART TX Pin)
; **


RST CON 13 ;Pin-16/Connected to Reset Pin of the LCD Display
ATPIN CON 8 ;Pin-17/Connected to Air Temperature Sensor
FTIN CON 9 ;Pin-18/Connected to Floor Temperature Sensor

ATVAL VAR LONG
FTVAL VAR LONG
AIRTEMP VAR FLOAT
FLRTEMP VAR FLOAT
LCDSTAT VAR WORD

CLEAR ;Reset all variables to zero

LCDSTAT=65

SETHSERIAL1 H9600


SEROUT S_OUT,I9600,[0]
SEROUT S_OUT,I9600,["------------------------",13]
SEROUT S_OUT,I9600,["Resetting LCD....",13]

PAUSE 500
GOSUB LCDRESET


SEROUT S_OUT,I9600,["Display an A....",13]
HSEROUT [$54,$41,$01,$01,$FF,$FF]
GOSUB NAK

SEROUT S_OUT,I9600,["Display Text Room Temp....",13]
HSEROUT [$73,$00,$02,$03,$FF,$FF,"Room Temp:",$0]
GOSUB NAK

SEROUT S_OUT,I9600,["Display Text Floor Temp....",13]
HSEROUT [$73,$00,$03,$03,$FF,$FF,"Floor Temp:",$0]
GOSUB NAK

SEROUT S_OUT,I9600,["Display Text Floor Temp....",13]
HSEROUT [$73,$00,$04,$03,$FF,$FF,"Floor-1 Temp:",$0]
GOSUB NAK

SEROUT S_OUT,I9600,["Display Text Floor Temp....",13]
HSEROUT [$73,$00,$09,$03,$FF,$FF,"Floor-2 Temp:",$0]
GOSUB NAK

END

; ** Process to reset the LCD/Send Autobaud Command **
LCDRESET
LOW RST
PAUSE 1000
HIGH RST
PAUSE 1000
SEROUT S_OUT,I9600,["Sending AUTOBAUD command....",13]
HSEROUT [$55] ;Send AUTOBAUD command
GOSUB NAK
GOSUB NAK
RETURN

; ***********************************************************


; ** Process to clear the LCD Screen
LCDCLR
SEROUT S_OUT,I9600,["Clearing the LCD Screen....",13]
HSEROUT [$45] ;Send CLEARSCREEN command

GOSUB NAK

RETURN

NAK
HSERIN [LCDSTAT]
IF LCDSTAT=$15 THEN
SEROUT S_OUT,I9600,["Command Error:",DEC LCDSTAT,13]
ENDIF

IF LCDSTAT=6 THEN
SEROUT S_OUT,I9600,["Command OK:",DEC LCDSTAT,13]
ELSE
;SEROUT S_OUT,I9600,["Command returned: ",DEC LCDSTAT,13]
SEROUT S_OUT,I9600,["Command returned: ",13]
ENDIF
RETURN


Top
 Profile  
 
 Post subject: Re: HSERIN/HSEROUT differences between Nano-18/Nano-40?
PostPosted: Sat Oct 15, 2011 2:09 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
As far as the chips are concerned the UART hardware is identical, just on different pins. Simplify your program to output a string every 100ms and confirm that works. Then use a simple program to echo back anything received and confirm that works. Also make sure you are using the lastest Studio release. Let us know if one of these 2 tests failes and how it failes.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: HSERIN/HSEROUT differences between Nano-18/Nano-40?
PostPosted: Sat Oct 15, 2011 7:10 pm 
Offline
Guru

Joined: Sun Jan 03, 2010 8:01 am
Posts: 55
Location: Eau Claire, WI
Thanks for the response Nathan.

See the results below (I just jumpered the AUSART RX and TX pins togeather...just to verify this is what you wanted me to test):

Nano-40:
The program listed below without any issues; infact I removed the PAUSE 100 from the HSEROUT and HSERIN and the program still performed nornally.

Nano-18:
The code wouldn't even pass the first run of the FOR/NEXT loop! The index stated a value of 10 while the RX value was 0 no matter what I added for a PAUSE (I tried 100, 10, and 1000)

Just to verify that the HSEROUT is P2 (Pin-8 of the Nano) and the HSERIN is P5 (Pin-11 of the Nano).

While I am excited to find that I am not CRAZY I would also like to get this LCD up and running....so what would you like me to test next?

TXVALUE VAR WORD
RXVALUE VAR WORD
INDEX VAR WORD
CLEAR

TXVALUE=111

SETHSERIAL1 H9600

SEROUT S_OUT,I9600,[0]
SEROUT S_OUT,I9600,["Transmitting....",13]

FOR INDEX=10 to 100
TXVALUE=INDEX
HSEROUT [TXVALUE]
PAUSE 300
HSERIN[RXVALUE]
SEROUT S_OUT,I9600,["Index is: ",DEC TXVALUE,13]
SEROUT S_OUT,I9600,["RX Value:",DEC RXVALUE,13]
NEXT

Thanks-Brian


Top
 Profile  
 
 Post subject: Re: HSERIN/HSEROUT differences between Nano-18/Nano-40?
PostPosted: Sun Oct 16, 2011 7:20 am 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
For the fun of it, I also verified that it does not work on Nano 18. The program hangs after outputting the value of 10, it says it receives a value of 0 and hangs... (This is an older Nano 18)... Tried with both Studio 2...13 and 2...15

So pulled out logic analyzer and with P2 hooked up to P5 for this test, I received almost nothing, just one little blip. When I removed the jumper to P2 and only had P5 hooked up to analyzer, it looks like I am receiving the proper serial output. So it appears like the serial input is not working properly. I commented out the HSERIN to get the test program to output several values.

Note: when I put the jumper back on to P5, did not have the HSERIN, the output to the logic analyzer was again bad and the program would sometimes hang, other times would reset at random times....

So if LCD only needs output, you can probably get it to work, but it looks like issue with HSERIN...

Kurt


Top
 Profile  
 
 Post subject: Re: HSERIN/HSEROUT differences between Nano-18/Nano-40?
PostPosted: Sun Oct 16, 2011 11:36 am 
Offline
Guru

Joined: Sun Jan 03, 2010 8:01 am
Posts: 55
Location: Eau Claire, WI
Thanks Kurt for verifying my problem!

This problem appears to exist with both a Nano-18 I purchased last fall as well as a Nano-18 I just purchased a week back. I hope that this problem can be resolved with a "tweak" within Basic Micro Studio.

Thanks Kurt for the "work around idea" but the problem is that with the LCD that I am using requires a "ack" response before additional data can be sent to the LCD (data flow is bi-directional).


Top
 Profile  
 
 Post subject: Re: HSERIN/HSEROUT differences between Nano-18/Nano-40?
PostPosted: Sun Oct 16, 2011 11:50 am 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
Sounds like one of the OLED's I am using from 4DGL. I am currently using it in a remote control, but currently driving it with Arduino Mega with 4 USARTS...)

Have you tried simply using bitbng software serial (serout/serin) to see if it would work? It should be able to handle it, if you don't mind being in lock step (always do the serin right after you issue a command and wait for the ack). Yes I know it is not as nice as knowing you issued a command and when you get ready to issue a new command, checking to see if the ack for the previous command has arrived, but at least it could get you limping along.

Kurt


Top
 Profile  
 
 Post subject: Re: HSERIN/HSEROUT differences between Nano-18/Nano-40?
PostPosted: Sun Oct 16, 2011 4:43 pm 
Offline
Guru

Joined: Sun Jan 03, 2010 8:01 am
Posts: 55
Location: Eau Claire, WI
Kurt,

Yes...I'm using the µLCD-32PT(SGC) from 4D Systems. I hope that once I can get past these HSERIN/HSEROUT issues that I can FINALLY get to working on the touch screen interface that is a major part of the LCD that I am using for my Heating System (started on this project last fall but became so frustrated with the touch display that I let it gather dust over the summer :twisted: ).

I'll work on the wireless part of the project as I can use SERIN and SEROUT to communicate with the xBees; I really didn't have any luck using the serial commands with the LCD before...I suppose I could presue that route until we can resolve this issue.

Do you by chance know if this means that the Nano-18s have an internal bug with HSERIN/HSEROUT that will required the Nano-18s to be replaced or is this an issue that can be resolved with a Basic Micro Studio upgrade? Or is this a question that we should wait for Nathan to respond to?

Thanks again-Brian


Top
 Profile  
 
 Post subject: Re: HSERIN/HSEROUT differences between Nano-18/Nano-40?
PostPosted: Mon Oct 17, 2011 7:40 am 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
Brian wrote:
Do you by chance know if this means that the Nano-18s have an internal bug with HSERIN/HSEROUT that will required the Nano-18s to be replaced or is this an issue that can be resolved with a Basic Micro Studio upgrade? Or is this a question that we should wait for Nathan to respond to?

Fixing this issue is for sure something for Nathan as I am also just an end user who purchased a few Nanos to try them out. I mainly work with Atom Pros and Arduinos... My guess is that the fix will be an update to Studio. I believe the Nano is simply a PIC processor (16F88), that they have loaded a special boot loader onto and each time you download a program it is the complete software for the PIC...

If it were me, I would probably play around some and see if maybe some PIC registers were not properly initialized. Like maybe look at: RCSTA... Again I am not a PIC person, so not sure what all to look at and poke at.

Kurt


Top
 Profile  
 
 Post subject: Re: HSERIN/HSEROUT differences between Nano-18/Nano-40?
PostPosted: Mon Oct 17, 2011 9:59 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
If one of you could email me the program above that would be great. Im out of the office today. I expect its something simple. I may find a temporary work around or it may require an updated Studio worse case.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: HSERIN/HSEROUT differences between Nano-18/Nano-40?
PostPosted: Mon Oct 17, 2011 10:19 am 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
I emailed it to you...

Kurt


Top
 Profile  
 
 Post subject: Re: HSERIN/HSEROUT differences between Nano-18/Nano-40?
PostPosted: Tue Oct 18, 2011 7:30 am 
Offline
Guru

Joined: Sun Jan 03, 2010 8:01 am
Posts: 55
Location: Eau Claire, WI
Thanks Kurt for e-mailing Nathan the program.

I'll look forward from the workaround/update from Nathan!


Top
 Profile  
 
 Post subject: Re: HSERIN/HSEROUT differences between Nano-18/Nano-40?
PostPosted: Tue Oct 18, 2011 9:48 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
Seems the rx pin is being set as an output instead of an input when setting up the serial port. The temporary fix is to make the p2 pin explicitly an input after the sethserial1 command.

sethserial1 h9600

test var byte(10)

input p2

main
hserout [0xaa,0x55]
hserin main,10000,[test(0),test(1)]
serout s_out,i9600,[hex test(0)," ",hex test(1),13]
pause 100
goto main

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: HSERIN/HSEROUT differences between Nano-18/Nano-40?
PostPosted: Tue Oct 18, 2011 10:27 am 
Offline
Guru

Joined: Sun Jan 03, 2010 8:01 am
Posts: 55
Location: Eau Claire, WI
Yeah!

Thanks for finding a "work around" for this issue Nathan!
I will try this code as soon as I get home from work today!

Thanks again!


Top
 Profile  
 
 Post subject: Re: HSERIN/HSEROUT differences between Nano-18/Nano-40?
PostPosted: Tue Oct 18, 2011 12:53 pm 
Offline
Guru

Joined: Sun Jan 03, 2010 8:01 am
Posts: 55
Location: Eau Claire, WI
It's alive! Thanks Nathan! The suggested "work around" allows my code to execute as expected!

Till the next question.....Brian


Top
 Profile  
 
 Post subject: Re: HSERIN/HSEROUT differences between Nano-18/Nano-40?
PostPosted: Tue Oct 18, 2011 1:00 pm 
Offline
Guru

Joined: Sun Jan 03, 2010 8:01 am
Posts: 55
Location: Eau Claire, WI
Question for Kurt (or others),

I am having issues switching baud to 19200 for my 4D Systems LCD. Do you have some sample code to post (if not I've included mine). I've tried several attempts of where to put in the SETHSERIAL without any luck (the command times out). Any help would be great. Thanks again!

; ** Process to reset the LCD/Send Autobaud Command/Change Baud Rate **
LCDRESET
LOW RST
PAUSE 1000
HIGH RST
PAUSE 1500
SEROUT S_OUT,I9600,["Sending AUTOBAUD command....",13]
HSEROUT [$55] ;Send AUTOBAUD command
;PAUSE 1000
HSERIN [LCDSTAT]
GOSUB NAK

SEROUT S_OUT,I9600,["Increase baud to 19200....",13]
HSEROUT [$51,$08] ;Send AUTOBAUD command
SETHSERIAL1 H19200 ;I've moved this command both before and after the NAK without any luck
GOSUB NAK

RETURN

; *** ACK/NAK ***
NAK
HSERIN TY,100000,[LCDSTAT]
IF LCDSTAT=$15 THEN
SEROUT S_OUT,I9600,["Command Error:",DEC LCDSTAT,13]
ENDIF

IF LCDSTAT=6 THEN
SEROUT S_OUT,I9600,["Command OK:",DEC LCDSTAT,13]
ELSE
;SEROUT S_OUT,I9600,["Command returned: ",DEC LCDSTAT,13]
SEROUT S_OUT,I9600,["Command returned: ",DEC LCDSTAT,13]
ENDIF
RETURN

TY
SEROUT S_OUT,I9600,["RX Error",13]
PAUSE 50
END


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO