Hi,
Here are some steps to add the ability to read an analog value from a sensor attached to a Lynxmotion AL5 Robotic Arm (such as the RB-Lyn-843).
In the default FBS (FlowBotics Studio) app AL5 arm.fsp, the first 4 inputs of the SSC-32U (A, B, C, D) are used as digital inputs to trigger actions in the sequencer.
Therefore, we will use one of the other, free inputs for our example. For this case, we will use H as an analog input.
Start by opening the AL5 arm.fsp app in FBS and enter editor mode. You can do so by pressing SHIFT + ESC.
1) Browse to LM SC-32 Engine
You will need to make the software output a command to read an analog value (Vx, where “x” is the port name [A,B,C,D,E,F,G,H]). Since A,B,C,D are already in use, we will use H. This port is dedicated to analog input. You can read more about those commands in the SSC-32U manual on page 34. Once in editor mode, you will need to navigate to the module names “LM SC-32 Engine”.
First, double-click “ArmControl”. Then, double-click the unnamed large window. Then, browse to the lower left corner and double-click “LM SC-32 + Comport”.
2) Add analog reading command
Modify the command in the code to add the VH command as command #5. This will be added after the four latching digital reads already present.
3) Browse to "Decode Inputs"
You will need to make the software read the response from the SSC-32U with the extra data (value of VH as a byte).
First, browse back to “LM SC-32 + Comport”. Then, browse into “Read Inputs” and into “Decode Inputs”.
4) Modify "Read Inputs"
Once there, you will need to make a few modifications to get the data out.
First, you will need to change the number of inputs processed to 5 (was 4 by default).
Then, add an array splitter, a Ruby module and a new output.
You will need to link the 2nd input (top left). It is a string array (squiggly square with an S inside) containing the inputs. It is processed as a queue. When the number of inputs reaches 5, out process triggers.
You can link outputs/inputs by dragging from one to the other. In this case, hover your mouse over the string array and drag that connection to the input of the “Splitter”. Then, create a string object (press “S”) and link the black circle on the right of the splitter (its output) to the left of the string object (its input). Repeat the linking until output #4 (the fifth output) shows up.
Link the 5th output (#4) to the Ruby module input. Change the output of the Ruby module to an integer (circle with an I). To do so, right click on the output and choose a new type for it in the list that pops-up.
Then, create a new output (press “O”). You can rename it by right-clicking it and choosing “Rename”. Make sure it is below the other ones (should be the lowest output) to ensure the order is kept!
Once that is done, copy the code in the Ruby module seen in picture #0004. Then, link the new integer output of the Ruby module to your new output. It will change to match the type “integer”.
You now have a digital value (0-255) of the analog input of H!
5) Consume the new output
We will now need to bring this output out to the main interface (a few levels up). To do so, we must add outputs that we can chain.
First, add a new output one level up to the “Read Inputs” module (see image 0005 for details).
6) Consume the new output - part 2
Add another output to “LM SC-32 + Comport”. Again, make sure the new output is the lowest one to respect the existing order of the current outputs.
7) Consume the new output - part 3
Now, we get to add a display of the value on the screen.
Search for the label object and drag one onto the current schema (see image 0007 for details).
8] Consume the new output - part 4
Add a new input (press “I”), a new integer object (press “D”) and link them together with the label.
9) Link the output to label
Go back up one level to the unnamed module. Add link between our “VH” output to the label.
10) Place the new output on GUI
Go back up two levels to the “ArmControl” module. If you are connected to the SSC-32U and have the FSR connected to the input H, you should see a number in the top right corner of the module. If it is always “0”, then you may not be connected or the input may not be physically tied to H. Check those first.
11) Move the label
You can then simply click the label (when selected, it will have a white rectangle on it). This will allow you to move it around by dragging.
We placed ours next to the digital inputs.
Please note you can always learn more here:
FlowBotics Studio - Developer Zone
FlowBotics Studio - User Guide
FlowBotics Studio - Component Reference