BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Tue Apr 24, 2018 3:43 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Software Problem
PostPosted: Mon May 30, 2016 10:15 pm 
Offline
Citizen

Joined: Sun Apr 22, 2012 10:22 pm
Posts: 26
In the attached code a red LED is turned on queing the operator to press a button. Then the Nano18 reads an angle sensor via
the A/D converter and places the value in a variable called Stall_angle. Once this occurs the red LED is turned off and a green LED
is turned on to signal the operator to fly at a different angle. When stable at that desired angle the operator pushes the same button
and the green LED is supposed to turn off and the A/D again measures the angle and saves into variable Fast_angle.
However the green LED never goes off no matter how many times you press the button.
Can you see why this doesn't happen? The program appears to lock up here.
Thanks.


Attachments:
Code problem.txt [2.12 KiB]
Downloaded 222 times
Top
 Profile  
 
 Post subject: Re: Software Problem
PostPosted: Fri Jun 03, 2016 8:49 pm 
Offline
Master

Joined: Wed Oct 19, 2011 2:28 am
Posts: 123
Hi,

I think that the only way that you are not going to be able to clear the green led is if when you do the 2 reading of P9 the two reading are not equal. You will branch to Wait_press2. If both reading are the same then you will clear the green led. To see if the two reading are not the equal I would print the 2 values to see if they are the same or for a test do a Fast_angle = 500 and Check_angle = 500 and see if the green led clear out.

ADIN p9, Fast_angle '<<<<<<<<<<<<<<<
Serout s_out, i9600,["Fast angle = ", Fast_angle,13]
Fast_angle = 500
ADIN p9, Check_angle '<<<<<<<<<<<<<<<
Serout s_out, i9600,["Fast angle = ", Check_angle ,13]
Check_angle = 500
IF Fast_angle <> Check_angle THEN GOTO Wait_press2 ; must have agreement.
'Both angles recorded in RAM, now write to EEPROM.
LOW p4


Top
 Profile  
 
 Post subject: Re: Software Problem
PostPosted: Fri Jun 03, 2016 11:32 pm 
Offline
Citizen

Joined: Sun Apr 22, 2012 10:22 pm
Posts: 26
Thanks for looking at my code. I can't print out anything because the Nano is plugged into it's dedicated circuit board, not in the programming fixture. The circuit is battery operated for portable operation and is not connected to any computer. It would be nice to monitor it and see what is happening. I don't believe that the 2 readings are not the same because when the first value is read (and re-read) it is always the same because the program continues on. Also, I tried commenting out the line that compares them and that did not fix it.


Top
 Profile  
 
 Post subject: Re: Software Problem
PostPosted: Sat Jun 04, 2016 1:03 am 
Offline
Master

Joined: Wed Oct 19, 2011 2:28 am
Posts: 123
Hi,
Try forcing to branch to the Set_speed before press the BUTTON command.


Wait_press2 'WAIT for pilot to press button at desired high speed point.
goto Set_speed 'Add this goto
BUTTON p12, 1, 20, 10, Workspace2, 1, Set_speed ; Debounce the button
GOTO Wait_press2

Also define the variable Workspace2 before the Main Example:

Workspace2 var =IN12

Main


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


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