State Machine to Control Progam Flow | Arduino Compatible Compiler for LabVIEW Discussions | Forum

Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 4 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
State Machine to Control Progam Flow
July 23, 2017
10:46 pm
Avatar
PC
Member
Forum Posts: 5
Member Since:
July 16, 2017
sp_UserOfflineSmall Offline

The attached VI uses a switch closure to move from frame 0 of a case structure to frame 1, where an analog input is read and sent to an LCD.

This program doesn't work in the manner expected. The program seems to stay in frame 0.

Any suggestions on why this doesn't work with the LabVIEW Arduino Compiler or a suggestion on how to accomplish this?

Thanks,

P.C.

July 24, 2017
1:00 pm
Avatar
filipealtoe
Admin
Forum Posts: 89
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Did you independently check what you are getting out of the Digital Read API vi you have inside case "0"? If that output never switches to true you would never get out of case "0". 

Cheers Filipe
July 24, 2017
10:37 pm
Avatar
PC
Member
Forum Posts: 5
Member Since:
July 16, 2017
sp_UserOfflineSmall Offline

Filipe,

Thanks for your suggestion. I put a switch from D2 (input) to ground and an LED/series resistor from D3 (output) to ground. Modified the VI to the one attached. When the switch is closed, the LED on D3 lights, as expected, but the program still doesn't move to Case 1.

Would you expect this program construction to work with your Arduino Compiler? If so, any other ideas of things to try?

Thanks,

P.C.

July 24, 2017
10:52 pm
Avatar
filipealtoe
Admin
Forum Posts: 89
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

I don't see anything jumping at me. How about getting rid of the local variable by turning that into a shift register? I wonder if the compiler is getting into a weird corner case.

Cheers Filipe
July 24, 2017
10:54 pm
Avatar
Steffan
Admin
Forum Posts: 301
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Move the SEQ# control out of the while loop.  In the documentation there are a few nuances of the compiler, one being the control value will be read at the location in code, so in this case, the variable created is getting re-set to 0 on each iteration of the loop.

July 24, 2017
11:42 pm
Avatar
PC
Member
Forum Posts: 5
Member Since:
July 16, 2017
sp_UserOfflineSmall Offline

Filipe and Steffan,

Thank you both for your suggestions. Filipe, your suggestion worked out very easily. The method that you suggested is shown in the attached VI. Anyone should be able to use this approach to step sequentially through their program after specific conditions are met in each step.

Steffan, haven't been able to find a way to define the variable SEQ# and have the program compile without errors.

P.C.

July 24, 2017
11:56 pm
Avatar
Steffan
Admin
Forum Posts: 301
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

PC said
Filipe and Steffan,

Thank you both for your suggestions. Filipe, your suggestion worked out very easily. The method that you suggested is shown in the attached VI. Anyone should be able to use this approach to step sequentially through their program after specific conditions are met in each step.

Steffan, haven't been able to find a way to define the variable SEQ# and have the program compile without errors.

P.C.

Shift Register should work just fine.  This is what I meant.  Just move SEQ# out of the while loop.  Compiles fine without errors.

seq.pngImage Enlarger

Attachments
August 29, 2017
6:23 pm
Avatar
RickyTerzis
New Member
Forum Posts: 1
Member Since:
August 29, 2017
sp_UserOfflineSmall Offline

Hi...i am a new user here. According to me you should check what you are getting out of the Digital Read API vi you have inside case "0"? If that output never switches to true you would never get out of case "0". 

Forum Timezone: UTC 0

Most Users Ever Online: 33

Currently Online:
2 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

John: 18

RTSLVU: 15

Dan6077: 11

Member Stats:

Guest Posters: 0

Members: 80

Moderators: 0

Admins: 3

Forum Stats:

Groups: 1

Forums: 2

Topics: 58

Posts: 289

Newest Members: Marielop, engladcub, AbbaLearilky, LeiylaWes, pavlik76Sed

Administrators: geadmin: 5, filipealtoe: 35, Steffan: 89