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

Spin code needed for OLED display "28087"

$
0
0
Hello there, I need some help.
I just started to learn the spin language weeks ago and I have passed through all the given lessons on the parallax homepage.
I can now write simple codes and from day to day I learn more - so far so good...
I have bought the new OLED display 96x64 (order number 28087) where I please need some code for it to keep this working.
I have read some projects and I have found C language code sequences only, but this (as a beginner) it is to strong for me to understand right now.
Ask me one year later - I just want to get knowledge on the Spin first...

So where can I get some simple codes for it?

What I want is simple. I have 2 voltages to measure and I want to display them at the same time at the display. Well, for now and if this will succeed, I can continue the basic code to more if I want...

Any proposal here?
(sorry for my english, I live in Germany, close to Hamburg. Thank you so much...

How to make a christmas tree reader for drag racing

$
0
0
Is it possible with today's technology to build or install a sensor that will pick up the first amber on Christmas Tree & activate delay box. If so what kind of supplies would I need & i also need a wiring Schematic.

Running Lights on Elev-8

$
0
0
Has anybody else made the Running Lights Kit for the Elev-8 from the OSH Park circuit boards?
I can not seem to get mine to work even though I can find nothing wrong in the physical build
of the circuits and followed the changes to the firmware. I have rechecked the firmware several
times and tested each individual board for shorts or wrong components. At a total loss right now
for what to do next.

Problem with MMA7455 Accelerometer and SimpleIDE Terminal

$
0
0
Hello,

I am using the MMA7455 3-Axis Accelerometer module (https://www.parallax.com/product/28526) on a Propeller Activity Board. I followed the SPI Example (http://learn.parallax.com/tutorials/language/propeller-c/propeller-c-simple-protocols/spi-example) and am using the provided code to take measurements on the z-axis. When I try to sample at 50Hz by changing the pause time from 500 to 20, the measurements in the SimpleIDE terminal cannot seem to keep up. The datasheet for the accelerometer says the chip can sample at up to 125Hz and 250Hz, depending on the bandwidth setting. Is the Propeller or SimpleIDE terminal the limiting factor or is there something I am doing wrong?

Thanks,
David

SimpleIDE Hang on Mac OSX 10.9

$
0
0
I was running through some of the Simple Multicore examples using SimpleIDE 1.0.2(RC2) for Mac against a Propeller Activity Board but SimpleIDE kept hanging when building the "Try This – Add Another Function, Run it in Another Cog " example. There was an error in my code, but it should not have caused a hang. I had to Force Quit the application to kill it.
I'm running Mac OS X 10.9.5

// This is the error that was seen in the Mac OS console:
Nov 21 22:08:09 jonnymos-mbp loginwindow[65]: *** WARNING: -[NSImage compositeToPoint:operation:] is deprecated in MacOSX 10.8 and later. Please use -[NSImage drawAtPoint:fromRect:operation:fraction:] instead.
Nov 21 22:08:09 jonnymos-mbp loginwindow[65]: *** WARNING: -[NSImage compositeToPoint:fromRect:operation:] is deprecated in MacOSX 10.8 and later. Please use -[NSImage drawAtPoint:fromRect:operation:fraction:] instead.
Nov 21 22:08:11 jonnymos-mbp com.apple.launchd.peruser.501[153] (com.Parallax.SimpleIDE.83808[511]): Exited: Terminated: 15
Nov 21 22:09:44 jonnymos-mbp com.apple.IconServicesAgent[201]: main Failed to composit image for binding VariantBinding [0x387] flags: 0x8 binding: FileInfoBinding [0x157] - extension: pages, UTI: com.apple.iwork.pages.pages, fileType: ????.
Nov 21 22:09:44 jonnymos-mbp quicklookd[605]: Warning: Cache image returned by the server has size range covering all valid image sizes. Binding: VariantBinding [0x203] flags: 0x8 binding: FileInfoBinding [0x103] - extension: pages, UTI: com.apple.iwork.pages.pages, fileType: ???? request size:32 scale: 1
Nov 21 22:09:46 jonnymos-mbp Console[165]: setPresentationOptions called with NSApplicationPresentationFullScreen when there is no visible fullscreen window; this call will be ignored.
Nov 21 22:11:01 jonnymos-mbp com.apple.launchd.peruser.501[153] (com.Parallax.SimpleIDE.83808[592]): Exited: Terminated: 15

Beginner Question

$
0
0
I'm a biology teacher that's been corralled to to teach about robots. I just opened the box and am using Mac OS 10.11.
I'm trying to figure out how to use the Shield Bot. I downloaded the Arduino IDE software. And started the first activity but I don't get anything like a Serial Monitor Window. I know the diagram is from Windows but I was told I could use Mac as well.
What am I missing?
Thanks.

LCD screen connection via vga type connector

$
0
0
Hello, I am trying to connect LCD monitor to the parallax chip using VGA type connection. I have to use as few pins of the parallax chips as possible for that task. from the schematic diagrams of the Propeller professional development board i noticed that 8 pins are required on the parallax chip to connect monitor using vga. Six of them uses red, green and blue color pins via different resistors. I wonder is that the only possible way for these pins to be connected. Can the number of pins used can be reduced in any way? I have attached the schematics, the diagram is in the page 7. If anyone has any ideals pleas share. Many thanks

Kind regards,
Mindaugas


Analog-to-Digital Converter problem on Propstick Board

$
0
0
Hello.
Im totally new in using propeller board. Currently still learning how to read an analog input in this board and display in serial terminal.

Previously, i already try the the simple analog to digital test instruction i've got here, using potentiometer, but when I turn the knob both way it always displaying "-1" value, instead of displaying actual voltage of potentio output.

Anybody can help me fix this problem? Could I use the PropBOE ADC object on my propstick?

Im using SPIN with PropStick board by the way.

Using the Chronodot (RTC) using C

$
0
0
I'm trying to use the Maxim DS3231SN RTC (Chronodot) with the Prop using C.

I know my circuit configuration is correct since I have successfully used Mike Green's Spin i2cObject_v2_1 to access the Chronodot (DS3231 registers are close to the DS1307).

When I run the attached code, the i2c_in() return value (bytesRead) is always 0.

Any suggestions / feedback would be most welcome.

Here is my source code:
#include "simpletools.h"

i2c *eeBus;

int main()
{
  eeBus = i2c_newbus(28,29,0);

  int timeData[12] = {0,0,0}; 

  int bytesRead = i2c_in(eeBus,0b1101000,0,1,timeData,3); 

  print("Bytes Read: %d\n", bytesRead);
  
  for (int index = 0; index < 3; index++)
    print("timeData[%d] = %d \n", index, timeData[index]);       
}

ActivityBot with SONY Remote

$
0
0
The Navigate With Infrared Flashlights tutorial for the ActivityBot was added to the rest of the ActivityBot tutorials on Friday:

http://learn.parallax.com/activitybot
http://learn.parallax.com/activitybot/navigate-infrared-flashlights

Here's a sneak peek at a related project that's coming soon to learn:

Circuit
http://learn.parallax.com/activitybot/build-ir-sensor-circuits
...although you can just use the IR receiver connected to P10.

Libraries
Copy the SONY Remote folder inside the attached zip to ...Documents/SimpleIDE/Learn/Simple Libraries/
Make sure you're running the latest version of SimpleIDE (0.9.43).
Restart SimpleIDE if it's running.

Test Code
Use the New Project button to create, name and save a new project.
Paste this code, then click Run with Terminal.
Point your remote at your ActivityBot and try pressing its various buttons. Verify that the digit keys match what's displayed as you press and hold them.
/*
  Test SONY Remote Keys.c
*/

#include "simpletools.h"                      // Library includes
#include "sonyremote.h"

int main()                                    // Main function
{
  ir_tLimit(1000);                            // -1 if no remote in 1 s

  while(1)                                    // Repeat indefinitely
  {
    print("%c ir key = %d%c",                 // Display key pressed
           HOME,       ir_key(10), CLREOL);
    pause(100);                               // 1/10 s before loop repeat
  }  
}


Navigation Code
Repeat the test code steps, but this time, use the Load EEPROM & Run button.
Unplug from the programming cable, and press and hold buttons to control. 2 or Channel up are forward, 8 or channel down are backward. 4 or volume down are turn left, 6 or volume up are turn right, and 1, 3, 7, and 9 are pivot keys.
/*
  ActivityBot SONY Remote Control.c
*/

#include "simpletools.h"                      // Library includes
#include "sonyremote.h"
#include "abdrive.h"

int key;                                      // Remote key variable

int main()                                    // Main funciton
{
  freqout(4, 2000, 3000);                     // Start beep
  drive_setRampStep(12);                      // 12 ticks/sec per 20 ms
  ir_tLimit(50);                              // Remote timeout = 50 ms

  while(1)                                    // Main loop
  {
    key = ir_key(12);                         // Get remote key code

    if(key == 2 || key == CH_UP)              // 2 or CH_UP -> Forward
      drive_rampStep(128, 128);
    if(key == 8 || key == CH_DN)              // 8 or CH_DN -> Backward
      drive_rampStep(-128, -128);
    if(key == 4 || key == VOL_DN)             // 4 or VOL_DN -> Left turn
      drive_rampStep(-128, 128);
    if(key == 6 || key == VOL_UP)             // 6 or VOL_UP -> Right turn 
      drive_rampStep(128, -128);
    if(key == 1)                              // 1 -> Left forward pivot
      drive_rampStep(128, 0);
    if(key == 7)                              // 7 -> Left backward pivot
      drive_rampStep(-128, 0);
    if(key == 3)                              // 3 -> Right forward pivot
      drive_rampStep(0, 128);
    if(key == 9)                              // 9 -> Right backward pivot
      drive_rampStep(0, -128);
    if(key == -1 || key == MUTE)              // no key or MUTE -> stay still
      drive_rampStep(0, 0);
  }  
}

Linux client for BlocklyProp

$
0
0
Hello,

I purchased an ActivityBot for my son. We assembled and wired it, and I am able to use SimpleIDE to build, load and run the "hello world" example. So far so good. The next thing I am trying to do is use BlocklyProp, at least until my son is old enough to understand the intricacies of the C language (at the very least he should know how to programme a Duff's device...). Alas, no Windows or Mac computers in our house.
A Google search pointed me to a Python-based client here:
https://github.com/parallaxinc/BlocklyPropClient

A few questions:
1. Is this an officially-supported client? Doesn't seem to be.
2. Is the project still active?
3. I got the client to work with the server hosted on blocklyprop.creatingfuture.eu (needed a couple of tweaks), which is not the one that the official site points to. That one does not work with the client at all.

Before I continue my debugging efforts or, worse, write my own client, is there a better way to get BlocklyProp on Linux?

Thanks,
--Elad

Simpletext print function and floats

$
0
0
The simpletext print function seems to have problems when printing floating point numbers.

I discovered this when converting a temperature measured with the DS18B20 temperature sensor to Fahrenheit. The sensor outputs the temperature in units of 1/16 degree Celsius and I am displaying the temperature in Fahrenheit with a precision of 0.1°. When the sensor returns a value of 0xff3c (-12.25°C) I expect the displayed value to be either 9.9 or 10.0 since the actual temperature is 9.95°F. Instead my display shows 0.0°F. I experimented with printing the conversion result with different number of digits after the decimal point.

When using the default number of digits the output is okay:
print("%f\n", 32+(9*(-196))/80.0);
results in displaying: 9.950001

When using one digit after the decimal point the problem is evident:
print("%.1f\n", 32+(9*(-196))/80.0);
results in displaying: 0.0

When using two digits after the decimal point the output is okay:
print("%.2f\n", 32+(9*(-196))/80.0);
results in displaying: 9.95

I looked at the source code for the simpletext library and I think the issue is in the float2string function. It has some code to determine the number of digits to print that isn't working.

propeller c

$
0
0
I am parsing a gps. When the clock hits 59 my screen jumps and sends a line of data below. Any ideas?? Thanks

// print("rmc magvar %s\n\n", _rmcmagvar);
print("day %d month %d year %d\n",day,month,year);

print("JD_adder %d\n\n",JD_adder);
print("A %d\n\n",A);
print("B %d\n\n",B);

// print("_gmathrs %d\n\n", _gmathrs);

// print("decimal_day %f\n\n", decimal_day);
// print("%c",NL);
print("%c",HOME);
pause(499);

Bluetooth App to control ActivityBot

$
0
0
Now that I have had my questions answered, I'd like to post a C-program that interfaces with a free android bluetooth joystick app to control the ActivityBot. The app is "Joystick BT Commander" by "Kas". It can be downloaded from GooglePlay. I'm using it on a Samsung Tablet 4, but the author says it works on a number of phones and tablets.

The link to the app is here:

https://play.google.com/store/apps/details?id=org.projectproto.btjoystick

The program below is setup to drive the ActivityBot using the joystick. There are 6 soft buttons on the app that can be used for any user defined function. I use 3 of them in the program to: end the program, as an emergency stop, and to turn ping on and off. The ping function is an example that simply lights the red and green channels of an RBG Led to show distance in front of the Bot to an object (<20cm = red, etc).

I intend to add my PIXY color tracking code as a function to be turned on and off using another button. When on, that code will take over driving the bot to go to a predefined colored object. The pixy code is at post 27 in:
http://forums.parallax.com/showthread.php/155501-Pixy-for-Propeller?p=1279736&highlight=pixy#post1279736

The comments in the code below explain the hardware connections and the BT commander data format. More info is available at the links on the app page on googleplay.

I hope that you find this interesting and something you can expand on.

Tom
/* C code for use with Propeller ActivityBot and Joystick BT Commander android App by Kas -

(c) T. Montemarano 2014-08-01,  MIT License

Tested with Samsung Tablet 4

2014-08-13 Deleted & from function name in cog_run statement, added 'flgping' flag to show when ping is running.

2014-08-12 Made global declaration of *cogping, increased cog stack sizes, fixed call to do_ping

2014-08-09  used 'volatile' in global declarations.
Written for BT Commander V5 - Changed protocol -- need to do data TX to android
coded BT button 6 as 'end' to terminate program
coded BT button 5 as E-stop  -- moving Joystick restarts movement
coded BT button 2 to turn ping on and off
Uncomment print statements and Run with terminal to debug or see command execution.

App options setup
Joystick Props -- behavior - deselect auto return to center
constraint - box
Buttons Props -- display 6
labels -- 1, 2 ping, 3, 4, - optional.  5 - E-stop, 6 - Quit (ends program)
Advanced -- auto connect - on
Refresh Interval - 100ms  (works, but I am going to check out other values)
Timeout - Off
Uses RN42 Blutooth module.  I'm using Sparkfun part that has same form as X-Bee socket
Connect BT DO to pin 9 (Will be Propeller Rx), BT DI to Prop pin 8 (will be Prop Tx)
Need to pair RN42 to android BT and connect (with ABot switch in position 1)
To run ActivityBot
Load to EEPROM, switch to 2, ABot will beep (piezo setup as in Learn examples)
After the beep and a second or so, the ABot will respond to the Joystick.
Try to tap the joystick position you want, since dragging results in
a lot of data being sent to the ABot.  (The app sends data when the position of the Joystick is changed)

Joystick data is x = -100 (Full Left), y=-100 (Full down), x=+100 full right, y=+100 full up.
The buttons are decoded as Ascii 'A' Button 1 lit, 'B' 1 grey, 'C' 2 lit, etc.  Button code is sent when button is pressed.

The Joystick zones are setup as approx +/- 15 y = 0 speed, +/- 15 x = drive straight fwd or back.
abs(y) >15 = move fwd (JS positive), move backwards (JS negative),
Abs(x) > approx 15 = add differential to y speed to turn or pivot (x positive -turn right.
Both x and y are scaled to set max speed and turning rates in the calculations of x2 and y2.
This can be played with to get a good range
Ping)) has signal connected to pin 5 with 2kohm resistor in series
common cathode rbg led has red to pin 6 with 100 ohm resistor, green to pin 7 with 120 ohm resistor, cathode to gnd.

To do: add pixy color tracking (use BT button 3) when active pixy tracking takes control and drives aBot to defined color object.

The BT app is free on Googleplay 'joystick BT Commander".  The link on the app page leads to the details
regarding the data protocols used.
*/

#include "simpletools.h"
#include "fdserial.h"
#include "abdrive.h"
#include "ping.h"

volatile char c1[9];
volatile int c0 = 1;
volatile int nbytes;
volatile int joydata;
int flgping;
int xval;
int yval;
int flgbt;
int dist;
int *cogping;

fdserial *blut;

void getbtjoy();
void do_ping();

int main()
{
freqout(4, 1000, 2000); // Speaker tone: 1 s, 2 kHz
int x2;
int y2;
int xy;
int yspd = 0;
int xspd = 0;
flgping = 0;                //    ping cog is not running
cog_run(getbtjoy, 220);
drive_ramp(0, 0);
while(c0)
{
if(nbytes == 8 )
{
pause(50);        //   try to get rid of pause
xy = joydata;
y2 = (xy & 511) - 200;
x2 = (xy >> 10) - 200;
printi("x = %d\n", x2);
printi("y = %d\n", y2);
yspd = (abs(y2) / 15) * 15;         // scale the fwd & rev motion
if(y2 <0) yspd = yspd / -2;         //  go slower in reverse
xspd = (abs(x2) / 15) * 4;          //  scale the turning
if(x2<0) xspd = xspd * -1;
printi(" left right %d %d\n",yspd+xspd, yspd-xspd);
drive_ramp(yspd+xspd, yspd-xspd);         // drive, turning differential added to yspd
}
if(nbytes == 3)
{
nbytes = 0;
printi(" button = %d\n\n", c1[2]);
if(c1[2]=='C')                  // Button 2, on turns on ping
{
cogping = cog_run(do_ping,120);
printi(" ping cog = %d\n\n", *cogping);
nbytes = 0;
flgping = 1;                      // set flgping -- ping cog is running
}
if(c1[2]=='D' && flgping)                // Button 2, off turns off ping, don't try to stop if not running
{
cog_end(cogping);
nbytes = 0;
flgping = 0;                      // clear flgping -- ping cog is stopped
}
}
} // end while c0
drive_ramp(0, 0);     // stop movement at end of program
//  printi(" end \n\n");
if(flgping) cog_end(cogping);       //  if ping running when quit is pressed, turn off
} // end main

void getbtjoy()
{
// fdserial * fdserial_open(int rxpin, int txpin, int mode, int baudrate)
blut = fdserial_open(9, 8, 0, 115200);
while(c0) // continue until button 6 - quit - is pressed
{
nbytes = 0;
int i = 1;
flgbt= 1;
c1[1] = fdserial_rxChar(blut); // read first byte from blut
if(c1[1] == 2) // if STX read next 7 bytes
{
flgbt = 1;
while(flgbt)
{
i++;
c1[i] = fdserial_rxChar(blut);
if((c1[i]==3) && (i==3 || i==8)) flgbt=0;
}       // end while flgbt, android string i = 2 => button, i = 7 => x,y values
if(i==8)
{
nbytes = 8;
xval = (c1[2] - 48) * 100 + (c1[3] - 48) * 10 + (c1[4] - 48);
yval = (c1[5] - 48) * 100 + (c1[6] - 48) * 10 + (c1[7] - 48);
joydata=(xval << 10) | yval;
} // end if i= 8
if(i==3)
{
nbytes = 3;
// printi(" button = %d\n\n", c1[2]);
}
if((i==3) && (c1[2]=='K' || c1[2]=='L'))      //  Button 6, ends program
{
c0 = 0;
//printi(" end \n\n");
}
if((i==3) && (c1[2]=='I'  || c1[2]=='J'))
{                      //E-stop on button 5 press, using JS restarts movement
drive_ramp(0, 0);
}
} // end if c1=2
} // end while c0
} // end getbtjoy

void do_ping()
{
while(1)
{
dist = ping_cm(5);
if(dist<=20)            // turn on red LED
{
high(6);
low(7);
}
else if(dist<=36)      // turn on yellow LED
{
high(6);
high(7);
}
else                    //  turn on green LED
{
low(6);
high(7);
}
pause(50);
}   // end while
}


Libraries

$
0
0
I have been off and on attempting to make a library using the formula in the learn prop c. I cannot get it to work. Copied and pasted or hand typed. Can't get the library to link with the test program.
Is there something I'm missing?

RN-42 and Propeller Board of Education Connection

$
0
0
I have the Propeller Board of Education mounted on a Boe Bot chassis and the Bluetooth RN-42. I want to program it remotely using Bluetooth. I am using BlockyProp and I am able connect to the RN-42 but I can't program my robot. I need to know what Propeller pins to connect the RN-42 too or information how to connect so I can program it.

Any help would be appreciated.

Thanks.

How signals work

$
0
0
Hello to anyone reading this!

I am pretty new (knowledge wise) to programming and electronics, so I have a question.

I wanted to start learning how to program a screen using VGA and a small OLED (with the Propeller) that Parallax sells, but I ran into a problem, it is a lot more complex than I thought it would be.

Although there is a lot that I need to learn, I want to know how the VGA signals from the Prop get sent to the adapter. I would have expected to see actual code (VGA spin driver in the Prop library) toggling pins to send the data, however, all I really seem to see is the data getting written to main memory.

In short, I do not know how the Prop sends the VGA adapter the signals. If anyone can explain this to me I would greatly appreciate it!

Additionally, if anyone knows about books that are informative on topics like these. And I am not talking about literally programming the Prop, but more like ones that could be used in teaching about the concepts of programming in a college course (maybe cheaper prices..).

If anyone is wondering... I am in college, but I am more focused on electrical engineering than computer engineering (hard/soft) because of the job market.


Thanks for all the help anyone is able to give!

Propeller C - Propeller Activity Board - Execute code from SD

$
0
0
Hello. I have heard that you can execute code on the PAB from an SD card, but after hours of scouring the internet from general ideas to very specific ideas, I have turned up with nothing. In one of the learning tutorials, the sd data one I believe, it mentions doing this later, but I never could find it. I also found that you could take byte code and cast it to a function pointer which I attempted to do here.
  sd_mount(DO, CLK, DI, CS);  FILE* fp = fopen("run.bin", "r");
  int size = 0;
  char c;
  while(fread(c, 1, 1, fp) != 0) {
    size++;
  }    
  fclose(fp);
  
  char code[size];
  
  fp = fopen("run.bin", "r");
  for(int i = 0; i < size; i++) {
    fread(c, 1, 1, fp);
    code[i] = c;
  }
  
  fclose(fp);
  
  ((void*)code)();
but failed to compile for obvious reasons. So now I ask for help from you, people of the forums. Please help me execute code from the sd card in the board.
Thank you.

Run With Terminal Error

$
0
0
Hello,

I am using the ActivityBot and I tested the encoders and they lit up fine. Then I calibrated my bot and it went fine too. Now when I went to see the interpolation table, I ran the code through the terminal and got an error when verifying RAM.
Verifying RAM ... Timeout Error!
error: load failed
error: load failed

Timeout Error!
error: load failed
error: load failed

Not sure what is happening but any help is appreciated and thanks in advance!

SimpleIDE Propeller "Run with Terminal" Error

$
0
0
I'm attempting to push test code to my propeller from Ubuntu 16.04 with SimpleIDE 1.0.1 and am getting the following error:

propeller-load -Dreset=dtr -I /opt/parallax/propeller-load/ -b ACTIVITYBOARD cmm/Welcome.elf -r -p /dev/ttyS0Error is : Permission denied
error: opening serial port '/dev/ttyS0'

Error is : Permission denied
error: opening serial port '/dev/ttyS0'

Is this an issue with the FTDI driver, or actual permissions? I've tried a few different things and have not had any success in getting the propeller to work with Linux. Any suggestions are greatly appreciated. Thanks.
Viewing all 293 articles
Browse latest View live