Brand New Intel Edison

Just got my new Intel Edison in the mail the other day, I convinced myself to order it to “Investigate” it for a project I am working on, but in reality I just wanted an excuse to buy one (Keep reading I actually bought 2).

 

To get started I just looked it up on the internet.

Above is the video I used to get started.  During the first night I ended up running the wrong linux commands causing my entire OS to get messed up (*note to self: make sure to run rm only on the specific directories you want to run it on, not everything)  This eventually messed up the Edison and I was unable to do anything with the Edison.  Using the instructions on this post (https://communities.intel.com/thread/58226) I was able to re install the OS and get the Edison working again.


Because I did not feel like dealing with switching the 1.8V logic to 3.3V or 5V logic I decided to pick up the arduino breakout board (This being my second Intel Edison).

To test out some basic functionality I hooked up a range finder sensor. I used some code from one of my other projects to get it going.  The code is very generic and can be found all over the internet if you are curious of how to use a range sensor.  (With the code below “Wire.h” should be apparently I cannot figure out how to make it not delete automatically)

#include "Wire.h"
#define trigPin A1
#define echoPin A0

void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop() {

  get_distance(trigPin, echoPin);

  Serial.println(" cm");
  delay(300);

}

void get_distance (int trig, int echo)
{
  long duration, distance;
  digitalWrite(trig, LOW);  
  delayMicroseconds(2); 
  digitalWrite(trig, HIGH);
  delayMicroseconds(10); 
  digitalWrite(trig, LOW);
  duration = pulseIn(echo, HIGH);
  distance = (duration/2) / 29.1;

  if (distance >= 500 || distance <= 0){
    Serial.print("Out of range ");
  } 
  else {
    Serial.print(distance);
  }
  Serial.print(" - ");
  delayMicroseconds(200);
}


I wanted to make sure that I could control the pins from python as well.  So After some research I found this library called Wiring-x86 (http://wiring-x86.readthedocs.org/getting_started.html)

To make my life easier, I just installed nano with “wget http://www.nano-editor.org/dist/v2.2/nano-2.2.6.tar.gz && tar xvf nano-2.2.6.tar.gz && cd nano-2.2.6 && ./configure && make && make install” – https://communities.intel.com/thread/55602

Just using the base code from https://github.com/emutex/wiring-x86/tree/master and the code worked fine.  This allowed me to control the LED on pin 13.

To double check all of this, I went to use the Blink example code set provided with the arduino IDE, I had issues at first loading the code, but after I reset the board It worked like a champ.  I am going to investigate why the board didn’t work on the first try with the arduino code, but I have a feeling it may be related to the wiring-x86 library I was using.  But I cannot say for certain yet.

Despite this being a new board to work with, there is a lot of information on the internet about it and how to use it, and the forums seem to be a good place for issues that you run into.

 

My  plan for these guys is to use it on my RC car project that I have been stalling on for over 2 years now.  But I am going to tackle that another day.

 

 

More Reading:

 

http://blog.dimitridiakopoulos.com/2014/09/10/hands-on-intel-edison/

http://jamidwyer.com/blog/node/35

http://fab-lab.eu/edison/

 

 

Beginning with the Parallax Propeller

It has been a while, a long while, but here is what I am working on tonight.

I recently picked up a Parallax Propeller.  After installing the software from the Parallax page I started to just mess around in code.  I am programming it in C.  With this being a multicore board the whole point is to use more than one core.

So before today I had never programmed anything using more than one thread.  So I had to do some research, found pthreads.h and went to work.  I also apparently forgot some basics about pointers, starting 8 threads all using the same pointer does exactly like it sounds like it does, the value is the same in all of them.  I tried setting the values of a variable and passing that in as a pointer to the creation of the thread, then change the value of the data in the memory and create another thread (and repeat a couple more times).  All I wanted to do was turn on all the lights on the board and then turn them off, what I got was all the lights turning on and the last one flickering.

After some careful thought I realized I made a rookie mistake, I used the same memory to store the  different values to pass into all the threads.  So I turned up with something that looked like this to make it better.

#include "simpletools.h"
#include <pthread.h>

typedef struct
{
  int light;
  int sleep;
} do_toggle_input;

void *do_toggle(void *argv)
{
  pthread_set_affinity_thiscog_np();
  do_toggle_input* vars = (do_toggle_input*)argv;
  printf("%d,%d\n",vars->light,vars->sleep);
  while(1)
  {
    high(vars->light);
    usleep(1000000);
    low(vars->light);
    usleep(1000000);
  }
}

void main (int argc,  char* argv[])
{
  pthread_t thr;
  do_toggle_input vars;
  void* var_ptr = &vars;
  usleep(200000);
  vars.sleep = 10000;
  vars.light = 16;
  var_ptr = &vars;
  printf("%d\n",vars.light);
  pthread_create(&thr, NULL, do_toggle, var_ptr);
  int i;
  for(i=16;i<24;i++)
  {
    vars.light = i;
    usleep(2000010);
    if(i==23)
    {
      i=15;
    }
  }
}

All this code does is turn on and off each light on the board, except if you notice the time is off, so it eventually switches over to all being on, and one being turned off and on.

One last thing to note, the struct that I use, I was using the sleep variable initially, but decided to hard code it.

Starting this Blog thing

So recently I have been informed that I should start a blog.  Apparently when you post very large rants on the Book of Face you should really use a blog.  So last night I decided to start a blog, and by decided I mean realized that what they suggested a blog be used for was not what I was going to do because normally I just like to post how happy I am or something I am excited about, and honestly who wants to read a blog about that.  

What I am going to start a blog about is challenges to myself.

What I am defining a challenge as: 

  1. Possibly just a project (Does not need to be challenging just fun, but could be a challenge)
  2. Something with a start and end point, not something vague.     
  3. Must be something that takes time (Aiming for 5 days or so in my spare time after work)             
  4. Hopefully technology oriented (Programming, electronics, etc)
  5. Something that stretches the mind

That is where I am going to start, I also hold the ability to change or negate any of the rules for any thing I want to do or that is suggested by the public. 

For instance one of the challenges I pose for myself for this blog is using Linux more, Now that won’t be on the 5 day work schedule, and since I work in Windows at work I cannot change that, but At home I am going to try to use Linux for everything (Eventually for this challenge).  Let me also point out that I have used Linux before so this is not something new to me, I just think that making a point to myself to do something I want to do is important and if this is how I get myself to do it then so be it. (I’m Lazy) But as you can tell no start or end point, well no end point so far, and the start point is not defined either, maybe I will do this for the “challenge” but not at this point. 

Public input is going to be important to me, not just so I know people read my blog (although that is nice to know) but also so that If the public wants me to do a technology oriented challenge I know what they want and I can keep the readers happy.

Fans give me a reason to do this, if I make a promise to do this and everyone is watching making sure I do this then I will do this, otherwise it will fall to the side like many of my other personal projects. 

If someone notices grammar issues with my post or misspellings let me know (Just do not be mean about it), I try to keep an eye out normally but as many of my classmates from college would tell you I am terrible at English, too bad it is my native Language otherwise I would have a valid excuse.