Quantcast
Channel: Learn with BlocklyProp — Parallax Forums
Viewing all 293 articles
Browse latest View live

Blockly - EMIC 2 Text_to_Speech_demo

$
0
0
I rewrote my C program demo of the Parallax EMIC2 text to speech board using Blockly. The C program is here:
forums.parallax.com/discussion/163425/emic2-text-to-speech-demo-in-c-for-the-propeller

The Blockly page is here: blockly.parallax.com/blockly/projects.jsp#3982

The attachments show the blocks.

This was a confusing program to write using Blockly, specifically when getting numerical values from the terminal and then sending them to the EMIC2. I had a difficult time using the integer-to-string blocks. If I input int x from the terminal (it was an integer), and then used the integer to string block, the variable x was turned into a char (in the c code where variables are declared.) That resulted in errors. It is necessary to send numbers as strings to the EMIC2.

I had to make variable assignments of x =0, xstring = abcdefghijklmnop (repeated for y and answer) to make sure the variables started out as the correct type. But even then when I used the integer to string block, x (etc.) became a char and I got errors.

I also had to make dummy variables (xvalue = x) and then use xvalue in the integer slot and store the string of xvalue in xstring. Again looking at the C code, x remained an int, xvalue and xstring are both chars.

Another issue was when I wanted to send "x + y = answer" to the emic, I was not able to convert xvalue, yvalue, and avalue to xstring, ystring, and astring, and then send them to the emic2. The last value converted appears to have overridden the first two. In other words if xvalue =45, yvalue =15, and avalue = 60, if I converted all three of them to xstring, ystring, and astring and the sent them to emic, they were spoken as "60 plus 60 equals 60". They also printed to the terminal as 60 + 60 = 60. I resolved that by converting each variable and sending it before converting the next.

However, issues aside, Blockly is fun to use.

Tom

Bug in SimpleIDE?

$
0
0
For some reason I have to constantly pull the usb and relink the propeller. If I change something in the program and attempt to launch it the comport drops off.
Any ideas??

BlocklyProp tutorial posted: RFID Scan and Store in EEPROM

S3/BlocklyProp - best quality traces

$
0
0
Our middle school has an offer to display S3 traces in our public library. I want the students to re-run them to be as polished as possible. We use about 60 cm square sheets of poster paper. Below is what we do for best results. Any more suggestions?

Run at slow speed:
reduces over-shoot and squiggle coming out of turns.
however, leaves larger "bleed dot" when pivot turning

Get paper relaxed and as flat as possible:
use very flat table surface (laboratory bench)
carefully clean bench and paper of any small debris
relax paper with slightly damp cloth, stretch and tape to table then quick dry with fan.

Check wheels / tires:
tires cleaned witch damp cloth and dried by fan.
carefullly clean any small debris that will intro error to encoder setting of circumference.
tires well seated
tail ball clean and free-running
no hair wrapped around axles

Marker:
Keep one set of markers just for high-quality traces
Check that tip is sharp (not worn to be rounded, no extra fuzz)
ink is flowing (not slightly dry)
Shim around marker so is tightly seated in port:
eliminates some wiggle during the turns
reduces wiggle from re-seat as come out of turn

Size and position
double check scaling value in code so result fits on paper with margins correct for intended mat & frame
use preliminary run to hang on wall, back up and judge if want changes before final
establish start position and angle (before every trial run we make soft pencil marks at 3 contact points so can replicate)
If desired, scale so leave space on paper to tape on print of block code, print of text code and/or student name

At run:
Insert marker at last minute to reduce bleed spot
clear plenty of space beyond paper for wheels going off paper during turns

Code:
Include at start a pause and count-down beeps so know exactly when motion will start.

ToDo:
Experiment with papers of different surface finish and thickness
Experiment to see if there is a straight-line speed which is optimal: probably slow, maybe not slowest
Experiment to see if there is a turning speed...
Try thin-point markers instead of thick sharpies (but may not be dark enough to see the trace at a viewing distance)
Try lifting pen by hand during the pivot turns (we have not had success with sevor-lifter. A student might look at improvement using 3D printed parts)
Somehow use Foam-Core (and maybe vacuum press) to keep paper as flat as possible.

Any other suggestions?

Thanks, John

propgcc LCD driver for HD44780/KS0066

$
0
0
Does anyone know of a driver for a HD44780/KS0066 LCD (any of the usual ) for Propeller C?

I'm trying to decide if I should code my project in C or Spin. The project requires and LCD and I want to use one that doesn't have a backpack, which means I need an actual driver for the various RW, E, and data pins, etc. - not I2C or SPI or anything like that.

There's this, written in Spin: http://obex.parallax.com/object/337

In terms of languages I'd much prefer to write C, just because I know it so much better. But this driver is a major factor.

Any ideas?

Best, Brad

Blockly with WS2812s, ColorPal, S3, Ping))) Ultrasonic sensor (three videos)

$
0
0
I think the WS2812s are a pretty good demonstration of Blockly capabilities. This uses JonnyMac's driver run through Spin2CPP, then put into Blockly. A conglomeration of testing stuff to see that everything works right.

image

image

image

Ken Gracey

WS2812 and BlocklyProp: two examples posted!

Issue with block "terminal receive 32 bit number store in x"

$
0
0
When I tried my blockly program "text_to_speech_demo"
blockly.parallax.com/blockly/my/projects.jsp#3982

I found that the subject block had changed in operation. When I previously entered a number in the terminal window, the number showed up once. Now when I enter a number (such as 45) each keystroke is echoed back to the terminal window. So it shows up as 4455. The number received by the program is correct.

I just tried with the "terminal receive text store in" block and the same thing happens. Entered characters,numbers or text show double in the terminal window.

Is there a way to prevent the terminal from echoing keystrokes?

Thanks
Tom

problem Missing blockly programs ??

Using BlocklyProp with DIY-Propeller-Boards possible?

$
0
0
Hi everybody,

before I start fiddling around a question:

Can I use my DIY-Propeller-Chip-boards with BlocklyProp?

I only did a quick crossreading about BlocklyProp.

As it is a graphical language. It has a lot of pre-configured commands like motor-control- LED-control etc. which are preconfigured to certain portpins etc.. Do I have a chance to use some more generalised commands like "create PWM" or "create a RC-Servo-Signal", or "receive characters through an UART" on my DIY-Propeller-Boards or will this end up in a lot off errors the compiler is reporting?

best regards

Stefan

BlockyProp with S2?

$
0
0
Hi,

Is it possible to program the S2 with Blockyprop?

Thanks,
Ed

Standard Servo Command A Little Off?

$
0
0
I've only tested a couple of my standard parallax servos but both are showing the same inaccuracies. 0 degree command seems ok. 90 degree command is 3 degrees off (ie 93 instead of 90). 180 degree command is 7 degrees off (ie 187 instead of 180). Actually the 180 degree command hits the hard stop on the servo.

Anyone else seeing this behavior on their standard servos?

Boe-Bot Maze Navigation with QTIs

$
0
0
Boe-Bot Maze Navigation with QTIs
·
Maze navigation is the heart of many robotic competitions, including the Micromouse maze and the Trinity firefighting competitions.· It is considered by most to be the one of the most challenging competitions since it requires a fair amount of work and ingenuity.· This project introduces basic maze navigation logic by using the Boe-Bot® Robot and the QTI Line Follower AppKit to navigate through an electrical tape maze containing 90° left and right turns, T-intersections and even dead ends!


View Video Introduction (YouTube)

Download Source Code – Boe-Bot Maze Navigation

Getting Started

Before continuing, make sure that you have already completed this checklist.· Especially if you have not already completed the Robotics with the Boe-Bot text, do that before you continue here.· It’s a great way to get started with Robotics!
·
······· Complete all activities in Robotics with the Boe-Bot
······· Download the documentation for the QTI Line Follower AppKit and follow all instructions listed
······· Review the How to - Boe-Bot QTI Line Following with 4 QTI Sensors for in-depth information on how the line follower code works.· This will be important when modifying the code for maze navigation.

Parts Required

(1) Boe-Bot® Robot, assembled and tested
The parts below are included in the Boe-Bot Robot kit:
····· (1) Piezospeaker
····· (misc)· Jumper wires
(1) QTI Line Follower AppKit
The parts below are included in the QTI Line Follower AppKit:
····· (4) 3-pin Male-Male Headers
····· (4) QTI Sensor Modules
····· (4) 3/8” 4-40 pan-head screws
····· (4) 7/8” 4-40 pan-head screws
····· (4) 1” round standoffs
····· (4) 1/2" round spacers
····· (4) 10” servo cable extenders

Building the Circuits···········

Follow the instructions included with the QTI Line Follower AppKit.· Or, you can download them here.· Some hardware modifications are needed for this application.· In the AppKit instructions, each QTI is mounted edge to edge, but in this application, more spacing will be required between the QTIs so the Boe-Bot can detect turns and other obstacles.· Use Figure 1 as a guide and mount the QTIs so the two center QTIs are 0.8 cm apart, and the outermost sensors are 2 cm from the center QTIs.
·
Figure 1 – Mounted QTI Sensors

attachment.php?attachmentid=59877

Building the Maze

Figure 2 shows a maze with a variety of obstacles for the Boe-Bot to navigate, including short and long straight tracks, 90° left and right turns, a T-Intersection, and a Dead End.· These obstacles pose a number of navigation challenges that you can solve, and in doing so, improve your Boe-Bot’s performance in larger and more complex mazes.· When constructing your maze, use a large piece of poster board and make sure each lane stripe is 1.5 inches of black vinyl electrical tape thick.· Figure 2 shows the maze designed for this activity (not to scale).
·
Figure 2 – Boe-Bot Electrical Tape Maze

attachment.php?attachmentid=59878

Calibration, Calibration, and More Calibration

Before we begin, you should know that the last program in this project may be larger than the example programs you may have tried in Robotics with the Boe-Bot.· That’s because there are a lot of conditions that have to be taken into account!· This “mini project” demonstrates how to take a complex problem and break it down into small pieces in order to successfully solve it.· In order to do this, we’re going to have to calibrate our Boe-Bot to maneuver through each condition before putting the whole thing together.· This will save us time when troubleshooting if we know that each individual piece works as it should.

attachment.php?attachmentid=74107

Moving Forward

Since the Boe-Bot will need to move slowly at some points in the maze, we’ll have to slow down the servos form the normal 850, 650 PUSLOUT durations.· This will help ensure that QTI readings aren’t missed as the Boe-Bot navigates through the maze, and you can use the same testing procedure introduced in Robotics with the Boe-Bot Chapter 4, Activity #2.· To slow forward movement, remember that a PULSOUT value of 750 stops the servo motors.· So we’ll want to pick values closer to 750 so the Boe-Bot slowly moves forward.· For further explanation, see the Rotational Velocity vs. Pulse Width for Servo graph in Robotics with the Boe-Bot Chapter 3, Activity #4.· Notice how the speed only really starts slowing as the pulses approach 700 from 650 and 800 from 850, so don’t worry if the change from 850 to 840 does not appear to have any effect.· Below is an adaptation of BoeBotForwardTenSeconds.bs2, and can be used to calibrate your Boe-Bot.

[color=#008000]' SlowlyForward.bs2[/color]
[color=#008000]' Calibrate your Boe-Bot to slowly move forward in a straight line.[/color]
 
[color=#008000]' {$STAMP BS2}[/color]
[color=#008000]' {$PBASIC 2.5}[/color]
 
[color=#000000]counter   VAR    Word[/color]
 
[color=#020FC0]FOR[/color][color=#000000] counter = 1 [/color][color=#020FC0]TO[/color][color=#000000] 407[/color]
  [color=#020FC0]PULSOUT[/color][color=#000000] 13, 770[/color]
  [color=#020FC0]PULSOUT[/color][color=#000000] 12, 730[/color]
  [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
[color=#020FC0]NEXT[/color]
 
[color=#020FC0]END[/color]


90° Left Turn Calibration

Once you’ve got the slow-forward code calibrated, the next step is to calibrate 90° turns.· There are a lot of them in the maze, so do a good job here.· It’s simple, and you’ve already calibrated your Boe-Bot to complete one in Robotics with the Boe-Bot Chapter 4, Activity #2…right?· If not, do not proceed until you are done with this important step! Now all we have to do is program the Boe-Bot to turn left when the maze path does.· You can set conditions for the Boe-Bot to follow using SELECT…CASE statements.· That way, if the QTIs are sending readings that the tell the BASIC Stamp the Boe-Bot needs to turn left, the BASIC Stamp can then send pulses to the servos to execute a 90° left turn.

attachment.php?attachmentid=74108
·
Use the sample code below and adjust the values as necessary so your Boe-Bot executes 90° left turns while staying centered on the maze path.

[color=#008000]' MazeNavigation_LeftTurn.bs2[/color]
[color=#008000]' Boe-Bot turns left based on values from the QTIs.[/color]
 
[color=#008000]' {$STAMP BS2}[/color]
[color=#008000]' {$PBASIC 2.5}[/color]
 
[color=#000000]qtis            VAR   Nib                 [/color][color=#008000]' qti black/white states[/color]
[color=#000000]pulseCount      VAR   Byte                [/color][color=#008000]' FOR..NEXT loop counter for turning[/color]
 
[color=#800080]OUTB[/color][color=#000000] = %1111                              [/color][color=#008000]' Set OUTB bits to 1[/color]
 
[color=#020FC0]DO[/color]                                        [color=#008000]' Main DO...LOOP[/color]
  [color=#020FC0]GOSUB[/color][color=#000000] Check_Qtis                        [/color][color=#008000]' Get QTI states[/color]
 
  [color=#020FC0]SELECT[/color][color=#000000] qtis                             [/color][color=#008000]' Control servo speeds/directions[/color]
    [color=#020FC0]CASE[/color][color=#000000] %0110                            [/color][color=#008000]' Straight ahead[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 13, 770[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 12, 730[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
    [color=#020FC0]CASE[/color][color=#000000] %1110[/color]
      [color=#020FC0]GOSUB[/color][color=#000000] Turn_Left[/color]
    [color=#020FC0]CASE[/color] [color=#020FC0]ELSE[/color]                             [color=#008000]' Do nothing[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 3[/color]
  [color=#020FC0]ENDSELECT[/color]
[color=#020FC0]LOOP[/color]
 
[color=#000000]Check_Qtis:[/color]
[color=#008000]' Checks the state of each QTI Sensor. 0 means white surface, 1 means black surface.  [/color]
  [color=#800080]DIRB[/color][color=#000000] = %1111                            [/color][color=#008000]'[/color] [color=#008000]P7..P4 -> output[/color]
  [color=#020FC0]PAUSE[/color][color=#000000] 0                                 [/color][color=#008000]' Delay = 230 us[/color]
  [color=#800080]DIRB[/color][color=#000000] = %0000                            [/color][color=#008000]' P7..P4 -> input[/color]
  [color=#020FC0]PAUSE[/color][color=#000000] 0                                 [/color][color=#008000]' Delay = 230 us[/color]
[color=#000000]  qtis = [/color][color=#800080]INB[/color]                              [color=#008000]' Store QTI outputs in INB[/color]
[color=#020FC0]RETURN[/color]
 
[color=#000000]Turn_Left:[/color]
  [color=#020FC0]FOR[/color][color=#000000] pulseCount = 0 [/color][color=#020FC0]TO[/color][color=#000000] 15                [/color][color=#008000]' Go forward a bit so Boe-Bot[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 13, 770                       [/color][color=#008000]' stays on course[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 12, 730[/color]
    [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
  [color=#020FC0]NEXT[/color]
  [color=#020FC0]FOR[/color][color=#000000] pulseCount = 0 [/color][color=#020FC0]TO[/color][color=#000000] 24                [/color][color=#008000]' Turn left, about 90-degrees[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 13, 650[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 12, 650[/color]
    [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
  [color=#020FC0]NEXT[/color]
[color=#020FC0]RETURN[/color]


90° Right Turn Calibration

Calibrating your Boe-Bot to execute 90° right turns works the same way as calibrating left turns.· These values probably won’t be a mirror image of left turns, so it’s important to test and find the necessary PULSOUT Duration Values to make the right turns as reliable as the left turns.· Use the sample code below and adjust the values as necessary so your Boe-Bot executes 90° right turns while staying centered on the maze path.

[color=#008000]' MazeNavigation_LeftTurn.bs2[/color]
[color=#008000]' Boe-Bot turns left based on values from the QTIs.[/color]
 
[color=#008000]' {$STAMP BS2}[/color]
[color=#008000]' {$PBASIC 2.5}[/color]
 
 
[color=#000000]qtis            VAR   Nib                 [/color][color=#008000]' qti black/white states[/color]
[color=#000000]pulseCount      VAR   Byte                [/color][color=#008000]' FOR..NEXT loop counter for turning[/color]
 
[color=#800080]OUTB[/color][color=#000000] = %1111                              [/color][color=#008000]' Set OUTB bits to 1[/color]
 
[color=#020FC0]DO[/color]                                        [color=#008000]' Main DO...LOOP[/color]
  [color=#020FC0]GOSUB[/color][color=#000000] Check_Qtis                        [/color][color=#008000]' Get QTI states[/color]
 
  [color=#020FC0]SELECT[/color][color=#000000] qtis                             [/color][color=#008000]' Control servo speeds/directions[/color]
    [color=#020FC0]CASE[/color][color=#000000] %0110                            [/color][color=#008000]' Straight ahead[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 13, 770[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 12, 730[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
    [color=#020FC0]CASE[/color][color=#000000] %0111[/color]
      [color=#020FC0]GOSUB[/color][color=#000000] Turn_Right[/color]
    [color=#020FC0]CASE[/color] [color=#020FC0]ELSE[/color]                             [color=#008000]' Do nothing[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 3[/color]
  [color=#020FC0]ENDSELECT[/color]
[color=#020FC0]LOOP[/color]
 
[color=#000000]Check_Qtis:[/color]
[color=#008000]' Checks the state of each QTI Sensor. 0 means white surface, 1 means black surface.  [/color]
  [color=#800080]DIRB[/color][color=#000000] = %1111                            [/color][color=#008000]'[/color] [color=#008000]P7..P4 -> output[/color]
  [color=#020FC0]PAUSE[/color][color=#000000] 0                                 [/color][color=#008000]' Delay = 230 us[/color]
  [color=#800080]DIRB[/color][color=#000000] = %0000                            [/color][color=#008000]' P7..P4 -> input[/color]
  [color=#020FC0]PAUSE[/color][color=#000000] 0                                 [/color][color=#008000]' Delay = 230 us[/color]
[color=#000000]  qtis = [/color][color=#800080]INB[/color]                              [color=#008000]' Store QTI outputs in INB[/color]
[color=#020FC0]RETURN[/color]
 
[color=#000000]Turn_Right:[/color]
  [color=#020FC0]FOR[/color][color=#000000] pulseCount = 0 [/color][color=#020FC0]TO[/color][color=#000000] 15                [/color][color=#008000]' Go forward a bit so Boe-Bot[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 13, 770                       [/color][color=#008000]' stays on course[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 12, 730[/color]
    [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
  [color=#020FC0]NEXT[/color]
  [color=#020FC0]FOR[/color][color=#000000] pulseCount = 0 [/color][color=#020FC0]TO[/color][color=#000000] 24                [/color][color=#008000]' Turn right, about 90-degrees[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 13, 850[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 12, 850[/color]
    [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
  [color=#020FC0]NEXT[/color]
[color=#020FC0]RETURN[/color]


T-Intersection Calibration

Alright, now what happens when the Boe-Bot encounters a T-Intersection?· One solution, which we will use here, is to program the Boe-Bot to make a random decision when it reaches the· T-Intersection.· We can do this by generating a pseudo-random number, and then turn left or right based a single bit of that random number (0 or 1).
·
In MazeNavigation_TIntersection.bs2, a pseudo-random number ranging from 0 to 65535 is generated each time through the Main loop using the RANDOM command.· By looking at a single bit of that number, the Boe-Bot can turn left or right depending if the value of that bit is 0 or 1.
·

attachment.php?attachmentid=74109

Using MazeNavigation_TIntersection.bs2, complete the following tests:

······· Run the code, and use the Debug Terminal to verify that you get pseudo random results each time
······· Press the reset button and move the Boe-Bot along a straight track until it reaches a T-Intersection
······· Repeat this process several times and verify that the turn results vary each time the T-Intersection is reached.

[color=#008000]' MazeNavigation_TIntersection.bs2[/color]
[color=#008000]' When all QTI sensors detect a black line, the Boe-Bot randomly decides to turn[/color]
[color=#008000]' left or right.  This codes simulates the decision by printing "Turn Left!" or[/color]
[color=#008000]' "Turn Right!" to the debug terminal.[/color]
 
[color=#008000]' {$STAMP BS2}[/color]
[color=#008000]' {$PBASIC 2.5}[/color]
 
 
[color=#000000]rng             VAR   Word                [/color][color=#008000]' random number[/color]
[color=#000000]turnDecision    VAR   rng.BIT0            [/color][color=#008000]' Bit0 of the random number[/color]
[color=#000000]qtis            VAR   Nib                 [/color][color=#008000]' qti black/white states[/color]
 
[color=#800080]OUTB[/color][color=#000000] = %1111                              [/color][color=#008000]' Set OUTB bits to 1[/color]
[color=#020FC0]DEBUG[/color] [color=#800080]CLS                                  [/color][color=#008000]' Clear the Debug screen[/color]
 
[color=#020FC0]DO                                        [/color][color=#008000]' Main DO...LOOP[/color]
  [color=#020FC0]GOSUB [/color][color=#000000]Check_Qtis                        [/color][color=#008000]' Get QTI states[/color]
  [color=#020FC0]RANDOM [/color][color=#000000]rng                              [/color][color=#008000]' Create random number[/color]
 
  [color=#020FC0]SELECT [/color][color=#000000]qtis                             [/color][color=#008000]' Control servo speeds/directions[/color]
    [color=#020FC0]CASE [/color][color=#000000]%0110                            [/color][color=#008000]' Straight ahead[/color]
      [color=#020FC0]PULSOUT [/color][color=#000000]13, 770[/color]
      [color=#020FC0]PULSOUT [/color][color=#000000]12, 730[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
    [color=#020FC0]CASE [/color][color=#000000]%1111[/color]
      [color=#020FC0]GOSUB [/color][color=#000000]T_Intersection[/color]
    [color=#020FC0]CASE [/color][color=#000000]ELSE                             [/color][color=#008000]' Do nothing[/color]
      [color=#020FC0]PAUSE [/color][color=#000000]3[/color]
  [color=#020FC0]ENDSELECT[/color]
[color=#020FC0]LOOP[/color]
 
[color=#000000]Check_Qtis:[/color]
[color=#008000]' Checks the state of each QTI Sensor. 0 means white surface, 1 means black surface[/color]
  [color=#800080]DIRB[/color][color=#000000] = %1111                            [/color][color=#008000]' P7..P4 -> output[/color]
  [color=#020FC0]PAUSE [/color][color=#000000]0                                 [/color][color=#008000]' Delay = 230 us[/color]
  [color=#800080]DIRB[/color][color=#000000] = %0000                            [/color][color=#008000]' P7..P4 -> input[/color]
  [color=#020FC0]PAUSE [/color][color=#000000]0                                 [/color][color=#008000]' Delay = 230 us[/color]
[color=#000000]  qtis = [/color][color=#800080]INB[/color]                              [color=#008000]' Store QTI outputs in INB[/color]
[color=#020FC0]RETURN[/color]
 
[color=#000000]T_Intersection:[/color]
  [color=#020FC0]IF [/color][color=#000000](turnDecision = 0) [/color][color=#020FC0]THEN[/color]
    [color=#020FC0]DEBUG [/color][color=#ff0000]"Turn Right!"[/color][color=#000000], [/color][color=#800080]CR[/color]
    [color=#020FC0]PAUSE [/color][color=#000000]100[/color]
  [color=#020FC0]ELSEIF [/color][color=#000000](turnDecision = 1) [/color][color=#020FC0]THEN[/color]
    [color=#020FC0]DEBUG [/color][color=#ff0000]"Turn Left!"[/color][color=#000000], [/color][color=#800080]CR[/color]
    [color=#020FC0]PAUSE [/color][color=#000000]100[/color]
  [color=#020FC0]ENDIF[/color]
[color=#020FC0]RETURN[/color]


Dead End Navigation and “Artificial Intelligence”

The dead end is another common maze obstacle, and therethththth are a lot of different approaches to solve this problem.· The program below handles it in the following way: tthe Boe-Bot will back up until it reaches the turn that led to the dead end, and then it will execute a 90° turn to get back on the maze path.
·
But what then?· The Boe-Bot still made another turn that brought it to the dead end, and if it makes that turn again, it will return to start instead of continuing to the end.· One way to solve this problem would be to create a new variable.· Let’s call it “AI”. When this variable is equal to 1, the Boe-Bot will ignore the left turn that would take it back to Start.· By creating a new subroutine named “AI_Decision”, the Boe-Bot can execute left turns based on the value of the AI variable.
·
Use the following code to verify that your Boe-Bot can successfully navigate its way out of a dead end.· Remember, some tweaking may be required!
[color=#008000]' MazeNavigation_DeadEnd.bs2[/color]
[color=#008000]' Boe-Bot backs up until it notices a turn and then moves forward again.[/color]
 
[color=#008000]' {$STAMP BS2}[/color]
[color=#008000]' {$PBASIC 2.5}[/color]
 
[color=#000000]qtis            VAR   Nib                 [/color][color=#008000]' qti black/white states[/color]
[color=#000000]AI              VAR   Byte                [/color][color=#008000]' "Artificial Intelligence" remembers dead ends[/color]
[color=#000000]pulseCount      VAR   Byte                [/color][color=#008000]' FOR..NEXT loop counter for turning[/color]
 
[color=#800080]OUTB[/color][color=#000000] = %1111                              [/color][color=#008000]' Set OUTB bits to 1[/color]
 
[color=#000000]DO                                        [/color][color=#008000]' Main DO...LOOP[/color]
  [color=#020FC0]GOSUB[/color][color=#000000] Check_Qtis                        [/color][color=#008000]' Get QTI states[/color]
 
  [color=#020FC0]SELECT[/color][color=#000000] qtis                             [/color][color=#008000]' Control servo speeds/directions[/color]
    [color=#020FC0]CASE[/color][color=#000000] %0110                            [/color][color=#008000]' Straight ahead[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 13, 770[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 12, 730[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
    [color=#020FC0]CASE[/color][color=#000000] %1110[/color]
      [color=#020FC0]GOSUB[/color][color=#000000] AI_Decision[/color]
    [color=#020FC0]CASE[/color][color=#000000] %0000                            [/color][color=#008000]' Back-up until it sees another turn[/color]
      [color=#020FC0]GOSUB[/color][color=#000000] Dead_End[/color]
    [color=#020FC0]CASE[/color] [color=#020FC0]ELSE[/color]                             [color=#008000]' Do nothing[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 3[/color]
  [color=#020FC0]ENDSELECT[/color]
[color=#020FC0]LOOP[/color]
 
[color=#000000]Check_Qtis:[/color]
[color=#008000]' Checks the state of each QTI Sensor. 0 means white surface, 1 means black surface[/color]
  [color=#800080]DIRB[/color][color=#000000] = %1111                            [/color][color=#008000]' P7..P4 -> output[/color]
  [color=#020FC0]PAUSE[/color][color=#000000] 0                                 [/color][color=#008000]' Delay = 230 us[/color]
  [color=#800080]DIRB[/color][color=#000000] = %0000                            [/color][color=#008000]' P7..P4 -> input[/color]
  [color=#020FC0]PAUSE[/color][color=#000000] 0                                 [/color][color=#008000]' Delay = 230 us[/color]
[color=#000000]  qtis = [/color][color=#800080]INB[/color]                              [color=#008000]' Store QTI outputs in INB[/color]
[color=#020FC0]RETURN[/color]
 
[color=#000000]AI_Decision:[/color]
  [color=#020FC0]IF[/color][color=#000000] (AI = 1) [/color][color=#020FC0]THEN[/color]                        [color=#008000]' If the AI variable is 1, Boe-Bot was in dead end[/color]
    [color=#020FC0]AI[/color][color=#000000] = 0                                [/color][color=#008000]' Set AI variable to 0[/color]
    [color=#020FC0]GOSUB[/color][color=#000000] Ignore_Turn                     [/color][color=#008000]' Ignore the turn that leads to Start[/color]
  [color=#020FC0]ELSEIF[/color][color=#000000] (AI = 0) THEN                    [/color][color=#008000]' If the AI variable is 0, Boe-Bot was not in[/color]
    [color=#020FC0]GOSUB[/color][color=#000000] Turn_Left                       [/color][color=#008000]' dead end, so it's OK to turn left.[/color]
  [color=#020FC0]ENDIF[/color]
[color=#020FC0]RETURN[/color]
 
[color=#000000]Ignore_Turn:[/color]
  [color=#020FC0]FOR[/color][color=#000000] pulseCount = 0 [/color][color=#020FC0]TO[/color][color=#000000] 50[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 13, 770[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 12, 730[/color]
    [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
  [color=#020FC0]NEXT[/color]
[color=#020FC0]RETURN[/color]
 
[color=#000000]Turn_Left:[/color]
  [color=#020FC0]FOR[/color][color=#000000] pulseCount = 0 [/color][color=#020FC0]TO[/color][color=#000000] 15                [/color][color=#008000]' Go forward a bit so Boe-Bot stays on course.[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 13, 770[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 12, 730[/color]
    [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
  [color=#020FC0]NEXT[/color]
  [color=#020FC0]FOR[/color][color=#000000] pulseCount = 0 [/color][color=#020FC0]TO[/color][color=#000000] 17                [/color][color=#008000]' Turn left, about 90-degrees[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 13, 650[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 12, 650[/color]
    [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
  [color=#020FC0]NEXT[/color]
[color=#020FC0]RETURN[/color]
 
[color=#000000]Dead_End:[/color]
  [color=#020FC0]DO[/color]
    [color=#020FC0]GOSUB[/color][color=#000000] Check_Qtis[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 13, 730[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 12, 770[/color]
    [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
  [color=#020FC0]LOOP[/color] [color=#020FC0]UNTIL[/color][color=#000000] (qtis = %0111)[/color]
 
  [color=#020FC0]IF[/color][color=#000000] (qtis = %0111) [/color][color=#020FC0]THEN[/color]
    [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
    [color=#020FC0]FOR[/color][color=#000000] pulseCount = 0 [/color][color=#020FC0]TO[/color][color=#000000] 15[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 13, 770[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 12, 730[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
    [color=#020FC0]NEXT[/color]
    [color=#020FC0]FOR[/color][color=#000000] pulseCount = 0 [/color][color=#020FC0]TO[/color][color=#000000] 17[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 13, 850[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 12, 850[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
    [color=#020FC0]NEXT[/color]
  [color=#020FC0]ENDIF[/color]
[color=#000000]  AI = 1[/color]
[color=#020FC0]RETURN[/color]


Keep the Boe-Bot on Track!

The final calibration step will be to write code that keeps the Boe-Bot centered on the electrical tape, since there are several factors that could knock it off course: the tape not being perfectly straight, slippage during turns, etc.· Keep in mind that line correction can be difficult when navigating through mazes, since there are a lot of different ways that the Boe-Bot can move off track, and each response would be different.· In the solution below, whenever the Boe-Bot detects that it has gone off course, it responds in as follows:

········· Stop
········· Slowly rotate until both middle sensors are back on the line
········· Turn slightly left/right depending which way the Boe-Bot went off track
········· Turn in the other direction slightly to center the Boe-Bot back on the line

This code was taken through several iterations of calibration, testing, recalibration, re-testing, etc.· Since the values may be completely different you may also have to go through several iterations of test and recalibrate.· Keep in mind that these steps are essential for successful line following though the maze, since the center sensors need to be on the line when moving forward.· Use the following steps to make sure the Boe-Bot can stay centered on the maze path:

······· Start with the far left sensor on the electrical tape and see how long it takes the Boe-Bot to center itself on the line
······· If you find that the Boe-Bot doesn’t correct fast enough, try increasing the pulseCount durations in the FOR...NEXT loops
······· On the other hand, if you find the Boe-Bot turns too far, try decreasing the pulseCount durations in the FOR…NEXT loops
······· Repeat with the far right sensor, far left and mid left sensors, and far right and mid right sensors
······· Once those values seem OK, try sliding the poster board to force the Boe-Bot to go off track and see how quickly it reacts


[color=#008000]' MazeNavigation_StayOnStripe.bs2[/color]
[color=#008000]' Calibration program to keep the Boe-Bot on the electrical tape path.[/color]
 
[color=#008000]' {$STAMP BS2}[/color]
[color=#008000]' {$PBASIC 2.5}[/color]
 
[color=#000000]qtis          VAR     Nib                 [/color][color=#008000]' qti black/white states[/color]
[color=#000000]pulseCount    VAR     Word                [/color][color=#008000]' FOR...NEXT loop counter for smooth turning[/color]
 
[color=#800080]OUTB[/color][color=#000000] = %1111                              [/color][color=#008000]' Set OUTB bits to 1[/color]
 
[color=#020FC0]DO[/color]                                        [color=#008000]' Main DO...LOOP[/color]
  [color=#020FC0]GOSUB[/color][color=#000000] Check_Qtis                        [/color][color=#008000]' Get QTI states[/color]
 
  [color=#020FC0]SELECT[/color][color=#000000] qtis                             [/color][color=#008000]'[/color] [color=#008000]Control servo speeds/directions[/color]
    [color=#020FC0]CASE[/color][color=#000000] %0110                            [/color][color=#008000]'[/color] [color=#008000]Mid Left and Right sensors detected, go forward[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 13, 770[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 12, 730[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
    [color=#020FC0]CASE[/color][color=#000000] %1000                            [/color][color=#008000]' Far Left sensor detected[/color]
      [color=#020FC0]GOSUB[/color][color=#000000] BackOnTrack_OneSensorLeft[/color]
    [color=#020FC0]CASE[/color][color=#000000] %1100                            [/color][color=#008000]' Far and Mid Left sensors detected[/color]
      [color=#020FC0]GOSUB[/color][color=#000000] BackOnTrack_TwoSensorsLeft[/color]
    [color=#020FC0]CASE[/color][color=#000000] %0001                            [/color][color=#008000]' Far Right sensor detected[/color]
      [color=#020FC0]GOSUB[/color][color=#000000] BackOnTrack_OneSensorRight[/color]
    [color=#020FC0]CASE[/color][color=#000000] %0011                            [/color][color=#008000]' Far and Mid Right sensor detected[/color]
      [color=#020FC0]GOSUB[/color][color=#000000] BackOnTrack_TwoSensorsRight[/color]
    [color=#020FC0]CASE[/color] [color=#020FC0]ELSE[/color]                             [color=#008000]' Do nothing[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 3[/color]
  [color=#020FC0]ENDSELECT[/color]
[color=#020FC0]LOOP[/color]
 
[color=#000000]Check_Qtis:[/color]
[color=#008000]' Checks the state of each QTI Sensor. 0 means white surface, 1 means black surface.  [/color]   
  [color=#800080]DIRB[/color][color=#000000] = %1111                            [/color][color=#008000]'[/color] [color=#008000]P7..P4 -> output[/color]
  [color=#020FC0]PAUSE[/color][color=#000000] 0                                 [/color][color=#008000]' Delay = 230 us[/color]
  [color=#800080]DIRB[/color][color=#000000] = %0000                            [/color][color=#008000]' P7..P4 -> input[/color]
  [color=#020FC0]PAUSE[/color][color=#000000] 0                                 [/color][color=#008000]' Delay = 230 us[/color]
[color=#000000]  qtis = [/color][color=#800080]INB[/color]                              [color=#008000]' Store QTI outputs in INB[/color]
[color=#020FC0]RETURN[/color]
 
[color=#000000]BackOnTrack_OneSensorLeft:[/color]
  [color=#020FC0]PULSOUT[/color][color=#000000] 13, 750                         [/color][color=#008000]' Stop[/color]
  [color=#020FC0]PULSOUT[/color][color=#000000] 12, 750[/color]
  [color=#020FC0]DO[/color]                                      [color=#008000]' Slowly rotate until the middle[/color]
    [color=#020FC0]GOSUB[/color][color=#000000] Check_Qtis                      [/color][color=#008000]' QTIs are back on the line[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 13, 750[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 12, 740[/color]
    [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
  [color=#020FC0]LOOP[/color] [color=#020FC0]UNTIL[/color][color=#000000] (qtis = %0110)[/color]
 
  [color=#020FC0]IF[/color][color=#000000] (qtis = %0110) [/color][color=#020FC0]THEN[/color]                  [color=#008000]' When the middle QTIs are back[/color]
    [color=#020FC0]FOR[/color][color=#000000] pulseCount = 1 [/color][color=#020FC0]TO[/color][color=#000000] 20              [/color][color=#008000]' on the line, rotate left for[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 13, 750                     [/color][color=#008000]' 20 pulses and then rotate right[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 12, 740                     [/color][color=#008000]' for 10 pulses to center the Boe-[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 20                            [/color][color=#008000]' Bot on the line.[/color]
    [color=#020FC0]NEXT[/color]
    [color=#020FC0]FOR[/color][color=#000000] pulseCount = 0 [/color][color=#020FC0]TO[/color][color=#000000] 10[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 13, 770[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 12, 750[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
    [color=#020FC0]NEXT[/color]
  [color=#020FC0]ENDIF[/color]
[color=#020FC0]RETURN[/color]
 
[color=#000000]BackOnTrack_TwoSensorsLeft:[/color]
  [color=#020FC0]PULSOUT[/color][color=#000000] 13, 750                         [/color][color=#008000]' Stop[/color]
  [color=#020FC0]PULSOUT[/color][color=#000000] 12, 750[/color]
  [color=#020FC0]DO[/color]
    [color=#020FC0]GOSUB[/color][color=#000000] Check_Qtis                      [/color][color=#008000]' Slowly rotate until the middle[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 13, 750                       [/color][color=#008000]' QTIs are back on the line[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 12, 740[/color]
    [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
  [color=#020FC0]LOOP[/color] [color=#020FC0]UNTIL[/color][color=#000000] (qtis = %0110)[/color]
 
  [color=#020FC0]IF[/color][color=#000000] (qtis = %0110) [/color][color=#020FC0]THEN[/color]                  [color=#008000]' When the middle QTIs are back[/color]
    [color=#020FC0]FOR[/color][color=#000000] pulseCount = 1 [/color][color=#020FC0]TO[/color][color=#000000] 20              [/color][color=#008000]' on the line, rotate left for[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 13, 750                     [/color][color=#008000]' 20 pulses and then rotate right[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 12, 730                     [/color][color=#008000]' for 10 pulses to center the Boe-[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 20                            [/color][color=#008000]' Bot on the line.[/color]
    [color=#020FC0]NEXT[/color]
    [color=#020FC0]FOR[/color][color=#000000] pulseCount = 0 [/color][color=#020FC0]TO[/color][color=#000000] 10[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 13, 770[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 12, 750[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
    [color=#020FC0]NEXT[/color]
  [color=#020FC0]ENDIF[/color]
[color=#020FC0]RETURN[/color]
 
[color=#000000]BackOnTrack_OneSensorRight:[/color]
  [color=#020FC0]PULSOUT[/color][color=#000000] 13, 750                         [/color][color=#008000]' Stop[/color]
  [color=#020FC0]PULSOUT[/color][color=#000000] 12, 750[/color]
  [color=#020FC0]DO[/color]
    [color=#020FC0]GOSUB[/color][color=#000000] Check_Qtis                      [/color][color=#008000]' Slowly rotate until the middle[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 13, 760                       [/color][color=#008000]' QTIs are back on the line[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 12, 750[/color]
    [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
  [color=#020FC0]LOOP[/color] [color=#020FC0]UNTIL[/color][color=#000000] (qtis = %0110)[/color]
 
  [color=#020FC0]IF[/color][color=#000000] (qtis = %0110) [/color][color=#020FC0]THEN[/color]                  [color=#008000]' When the middle QTIs are back[/color]
    [color=#020FC0]FOR[/color][color=#000000] pulseCount = 1 [/color][color=#020FC0]TO[/color][color=#000000] 20              [/color][color=#008000]' on the line, rotate right for[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 13, 760                     [/color][color=#008000]' 20 pulses and then rotate left[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 12, 750                     [/color][color=#008000]' for 10 pulses to center the Boe-[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 20                            [/color][color=#008000]' Bot on the line.[/color]
    [color=#020FC0]NEXT[/color]
    [color=#020FC0]FOR[/color][color=#000000] pulseCount = 0 TO 10[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 13, 750[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 12, 730[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
    [color=#020FC0]NEXT[/color]
  [color=#020FC0]ENDIF[/color]
[color=#020FC0]RETURN[/color]
 
[color=#000000]BackOnTrack_TwoSensorsRight:[/color]
  [color=#020FC0]PULSOUT[/color][color=#000000] 13, 750                         [/color][color=#008000]' Stop[/color]
  [color=#020FC0]PULSOUT[/color][color=#000000] 12, 750[/color]
  [color=#020FC0]DO[/color]
    [color=#020FC0]GOSUB[/color][color=#000000] Check_Qtis                      [/color][color=#008000]' Slowly rotate until the middle[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 13, 760                       [/color][color=#008000]' QTIs are back on the line[/color]
    [color=#020FC0]PULSOUT[/color][color=#000000] 12, 750[/color]
    [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
  [color=#020FC0]LOOP[/color] [color=#020FC0]UNTIL[/color][color=#000000] (qtis = %0110)[/color]
 
  [color=#020FC0]IF[/color][color=#000000] (qtis = %0110) [/color][color=#020FC0]THEN[/color]                  [color=#008000]' When the middle QTIs are back[/color]
    [color=#020FC0]FOR[/color][color=#000000] pulseCount = 1 [/color][color=#020FC0]TO[/color][color=#000000] 20              [/color][color=#008000]' on the line, rotate right for[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 13, 770                     [/color][color=#008000]' 20 pulses and then rotate left[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 12, 750                     [/color][color=#008000]' for 10 pulses to center the Boe-[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 20                            [/color][color=#008000]' Bot on the line.[/color]
    [color=#020FC0]NEXT[/color]
    [color=#020FC0]FOR[/color][color=#000000] pulseCount = 0 [/color][color=#020FC0]TO[/color][color=#000000] 10[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 13, 750[/color]
      [color=#020FC0]PULSOUT[/color][color=#000000] 12, 730[/color]
      [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
    [color=#020FC0]NEXT[/color]
  [color=#020FC0]ENDIF[/color]
[color=#020FC0]RETURN[/color]


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jessica Uelmen
Education Department
Parallax Inc.

Post Edited (Jessica Uelmen (Parallax)) : 8/25/2010 6:24:04 PM GMT

lsm9ds1 IMU get tilt along specified axis returns error: ...'__imuS' undeclared (first use)

$
0
0
Howdy,

Looks like the built code for this LSM9DS1 sensor includes an undeclared variable, '__imuS ' when compiling with BlocklyProp. It gives an error when trying to use the LSM9DS1 IMU's: "gets tilt along specified axis" command...

BlocklyCodeImage-IMU-Tilt-Error.jpeg

Error:
Required libraries: lsm9ds1, simpletools
Library compile order: None needed
single.c: In function 'main':
single.c:29:28: error: '__imuS' undeclared (first use in this function)
single.c:29:28: note: each undeclared identifier is reported only once for each function it appears in

C code created:
/* SERIAL_TERMINAL USED */
// ------ Libraries and Definitions ------
#include "simpletools.h"
#include "lsm9ds1.h"

// ------ Global Variables and Objects ------
float __imuX, __imuY, __imuZ, __compI;

int z_tilt;
int item;
int z_angle;

// ------ Main Program ------
int main()
{
    imu_init(12, 13, 14, 15);

    while (1)
    {
        imu_readAccelCalculated(&__imuX, &__imuY, &__imuZ);
        z_tilt = (int)(100.0 * __imuX);
        item = (int)(100.0 * __imuY);
        z_angle = (int)(100.0 * __imuZ);
        print(("angle: "));
        print("%d\r", z_angle);
        imu_readAccelCalculated(&__imuX, &__imuY, &__imuZ);
        item = (int)(atan2(__imuS, __imuY) * 180.0 / PI);                 // <-- __imuS is UNDECLARED
        z_tilt = (int)(atan2(__imuZ, __imuY) * 180.0 / PI);
        print(("tilt: "));
        print("%d\r", z_tilt);
    }

}

dgately

SimpleIDE not finding simpletext.h

$
0
0
I am on Linux Mint i686. I just installed SimpleIDE and I am trying to build the sample Hello World program and it is failing. Here is the error I am getting:
Project Directory: /home/user/Desktop/SimpleIDE/SimpleIDE/My Projects/

SimpleIDE Version 1.0.1
/home/user/Desktop/SimpleIDE/SimpleIDE/Learn/Simple Libraries/
/home/user/Desktop/SimpleIDE/SimpleIDE/ Updated on: 2016-05-02

propeller-elf-gcc -v GCC 4.6.1 (propellergcc_v1_0_0_2408)
propeller-elf-gcc -I . -L . -I /home/user/Desktop/SimpleIDE/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L /home/user/Desktop/SimpleIDE/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I /home/user/Desktop/SimpleIDE/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext -L /home/user/Desktop/SimpleIDE/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext/cmm/ -I /home/user/Desktop/SimpleIDE/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L /home/user/Desktop/SimpleIDE/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -o cmm/Welcome.elf -Os -mcmm -m32bit-doubles -fno-exceptions -std=c99 Welcome.c -lm -lsimpletools -lsimpletext -lsimplei2c -lm -lsimpletools -lsimpletext -lm -lsimpletools -lm
In file included from Welcome.c:26:0:
/home/user/Desktop/SimpleIDE/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/simpletools.h:111:24: fatal error: simpletext.h: No such file or directory
compilation terminated.
Done. Build Failed!

Click error or warning messages above to debug.

I have tried installing it to a different version of Mint that I booted from a LiveCD, and got the same problem. The header file "simpletext.h" exists, its just not being found for some reason (It is in "Simple Libraries/TextDevices/libsimpletext/simpletext.h").

Beta bugs

$
0
0
With a very simple program to initialize an array, a repeat loop for 10 times, calling a function to fill that array with the value of the repeat loop, and then using a second repeat loop to print out each of the ten values of the array. I ran this program about 25 times.

Three times it returned no output in the Terminal window. Then, around the 17th try I got the BlocklyProp message that it was unable to compile, try the Force Refresh,... Instead I saved it again and it ran once or twice but then same message.

A more complex program, also using an array and a function, and outputting to Terminal, seemed to work maybe twenty times but then it had a hard error. Looking at the C code said that the array had not been initialized. As if the array initialization statement was no longer there. The array initialization statement was active. I removed it and put a new one in. Now the C code had two error messages, each saying the array had not been initialized. Very odd.

Questions (knowing this is beta software):

1. When the Terminal returns no output, is that a problem with my Internet connection or something else ?

2. Is there a posted list of known problems with the BlocklyProp compiler and/or statements ? So maybe I could steer clear of some areas until the software gets more stable.

3. Another problem I've seen with Terminal is that even though the Terminal screen was cleared (setting the cursor to 0.0), when I print a binary number from an array, the very first space on Terminal has a zero in it, as does each subsequent line.

4. Are there future plans to have a few formatting options for the Terminal print statements so one could easily create an at least somewhat formatted output? I realize that this is not really the main purpose of having hardware do stuff..

Nevertheless, even after having to make a new project from scratch when the old one could no longer be fixed (would not compile) I still have had a lot of fun with BlocklyProp.

Thank you

Getting Started with the Parallax Serial LCD

$
0
0
Getting Started with the Parallax Serial LCD
·
Especially if you've been following along with the Stamps in Class texts, you're probably familiar with what a valuable tool the Debug Terminal can be.· It makes it possible to display messages and variable values, which in turn makes it possible to figure out what's going on with your program, test circuits and sensors.· Think about how many times it wasn't convenient to be connected to the computer to test a sensor, or find out what the Boe-Bot was seeing with its infrared sensors in another room.· This is one situation that a serial liquid crystal display (LCD) like the one in Figure 1 can remedy.
·
attachment.php?attachmentid=73672
·
attachment.php?attachmentid=73673
·
The items shown in Figure 2 all have liquid crystal displays.· They are easy to read, and the smaller ones consume very little power.· Think about how many products you own with liquid crystal displays.· Think also as you go through these activities about the various BASIC Stamp projects, prototypes and inventions you've got in the works, and how a serial LCD might help them to completion.
·
attachment.php?attachmentid=73674
·
attachment.php?attachmentid=73675
·
The activities in this chapter introduce how to use the Parallax Serial LCD with the BASIC Stamp 2.· LCD basics will include displaying text, numbers, placing and animating characters, and creating and animating custom characters.·
_____________________________________________________________________________
·
The draft material in this Topic·is part of a forthcoming Stamps in Class text by Andy Lindsay.
·
(c) 2005·by Parallax Inc - all rights reserved.··

Post Edited By Moderator (Jessica Uelmen (Parallax)) : 8/25/2010 5:48:06 PM GMT

New Tutorials Posted for BlocklyProp - Circuit Practice!

OLED initialization

$
0
0
After using the OLED initialize Block, and then looking at code, there is always an extra number in the code, so far a "2".

For example: oledc_init(9, 8, 7, 6, ,5, 2);

a. What is the purpose of the "2" ?

Wow!!, Blockly has grown

$
0
0
I looked through the "Propeller BlocklyProp Block Reference" on the Learn site today. It sure has gotten big with all of the new blocks. While there are still the simple blocks, there are also some fairly complex blocks. That's good for being able to do advanced programming and for students to expand their knowledge, but I wonder if new programmers will get lost with all the options.

It might be useful to have a "beginner's" reference along with the full reference.

Tom
Viewing all 293 articles
Browse latest View live




Latest Images