Feb 28, 2016

Reference and Material Links for all Posts

Reference and Material Links for all Posts

IDE Downloads: Intel XDK and Eclipse

SparkFun GPIO Block Product Page: (link here)
Webserver Example Code from Intel: (link here)
Putty Download: here

WiFi Configuration Article from Intel:
https://software.intel.com/en-us/connecting-your-intel-edison-board-using-wifi

Hardware Guide from Intel: Intel Download 

Using the GPIO Block to make an LED Blink: here
Article about how everything in Linux is a file: everything in linux is a file


Feb 25, 2016

Let's Blink some LEDs!!

HELLO WORLD!!!

Here is my current hardware hookup pictured above, pretty simple.
It's the GPIO Block with female headers, 2 Jumpers to a small solderless breadboard, a resistor and an LED. (I don't think this needs a schematic or diagram but if anyone wants one just ask and I will update this post).

Here is where it gets a little funny for me... we have basically a computer running Linux, and some GPIO...
How do we access these GPIO?
My previous work with microcontrollers would dictate writing a program, or directly writing to a given space in memory that would effect the state of the GPIO in question.

I know there are a million ways to skin a cat, but for right now all I want to do is blink an LED to validate my hardware hookup and also to gain some more knowledge about how one can do so with the Edison.

While researching I came across some pretty simple steps to do just that here.
Here are the broad strokes that I took along with some explanation about the commands.

We are working within the Operating System Linux, and if you didn't know...everything in linux is a file.

For our purposes this even includes the state of the GPIO... that is interesting... from that understanding what we can basically say is if you create / edit / alter the value of a specific file this will effect the GPIO.

Ok enough theory, let's get to it! Explanations / elaborations after the posted code:
From the terminal command line:

cd /sys/class/gpio
echo 14 > export
cd gpio14
echo out > direction
echo 1 > value





This code above does the following (as far as GPIO Hardware):
Changes GPIO 14 into an output
Makes GPIO 14 high

(I'd be happy to go into more detail about the commands themselves, perhaps in another post --> Eventual Link)

If you have an Edison and some form of breakout to access GPIO14, and you have executed the above commands, then you should be able to use a multi-meter to read a "high"  value on GPIO14. This may be 1.8V or 3.3V depending on your hardware.

In my particular case with the hardware I have hooked up (picture at top of post) this is what I get as a result:


As you can see the LED is now lit :D


The important part is that you've now crossed from "Inside the box" to "Outside the box", box in this case being a linux machine on WiFi ;)

This is exciting... it may just be a reading of 1.8V on a meter, or a lit LED at the moment. But truly this can be anything that you can think of.. Unlocking a door, Turning on lights...etc.

Some general background context about what we've just done:
  • GPIO means General Purpose Input Output --> These connections to the Edison or pins as I will reference them going forward, can be either an Input or an Output.
  • Not all pins are created equal --> Some pins have special functions or enhanced features that not every pin on the Edison can do, for now we are sticking with the most basic functions of the most basic type of GPIO or pin on the Edison. Just for reference; some of the "enhanced features" that IO pins (or groupings of pins) have on the Edison are: PWM, USB, UART, SPI, I2C. We'll be getting to those in time.
     
  • "Hello World" is a term that's used to describe the first program you'll write in a programming language. Usually it means having "Hello World" displayed on the screen. In the microcontroller world, the equivalent is blinking an LED.
Where shall I go from here?? Some thoughts (I'll add links to posts as I complete these ideas):
  • Making this Linux machine a webserver
  • Controlling LEDs from a web page 
  • Reading inputs of pins
  • Having LED output be based on results of other inputs

Ok that's it for the moment... Stay tuned for more... Comments / Requests will be acknowledged.


GPIO Now Accessible!!

Well at long last I received the small parts I was waiting on... almost all of them.
I have yet to receive pin headers but went ahead with some female pin headers that I found along with the jumpers I did receive.


As previously mentioned I am using the SparkFun GPIO Block.
Here are some pictures from soldering the female pin headers on the GPIO Block:













(Sorry about the layout of the pics... the built-in WYSIWYG editor of blogger is annoying but I promised myself I wouldn't get hung up on that while documenting this process.)

Anyway as you can see I have the female headers all soldered up and now the GPIO of the Edison is at our disposal!

Next post will be continuing our connections to this newly available hardware!!

Feb 12, 2016

On Installing Ubilinux...

(throat clearing)...
Oh wait it's done!!




Yeah, they boldly tell you you can brick your Edison in the process of doing this (installing Ubilinux).

What they should tell you is that it takes less than 5 minutes and includes a cup of coffee ;)




No Hardware Blues....

I'm going to have to wait a little bit to blink the LED.
I have no small parts like headers or jumper wires to make use of my breadboards.

I've ordered them though!

Meanwhile, the next step is to blink the LED via webpage served off of the Edison; why not begin that part now?

Then I ran across info that says Ubilinux (Debian) is better that Yocto. More Packages, Larger Community, OS has Fuller Feature Set...

So I'll do that, because I'm sure Ubilinux will have lots of options for webservers .

Off to it!


Feb 11, 2016

Ok;enough... It's time to get serious

Today I will blink the LED

Somethings I need to understand about the Edison first:
a-More about it's internal workings; when first learning about electronics I learned that you can't use an x86 platform running a full OS to control pin specific actions directly with discrete timing... things like stepper motors, servos...etc. I learned you have to use a microcontroller.

So far from what I can see about the Edison is it has a lot of labeled GPIO like a microcontroller but so far in interacting it's basically a full blown linux machine. I know so far there are commands to control the direction and status of a pin... but these are via command line so no discernible way to know how many milliseconds between when I execute that command and when the LED will light up... at least not that I can see yet.

I've seen the most examples so far with the Edison hooked up to an Arduino... This again leads me back to the conclusion that the Edison either needs a microcontroller attached to it, or that the Edison already is a linux box with a microcontroller attached to it (my guess is either via USB, SPI or something similar), and if my assumption is correct then I'd think they also share direct access to a bank of high-speed memory and a counter as well.

Anyway... I've just downloaded the: "Intel® Edison Compute Module; Hardware Guide, Jan 2015"
It's a 46 Page PDF written by Intel. Intel Download .

I'll find out my answers shortly and get this done!

Feb 8, 2016

Got it back to Normal ... WiFi configured


I found this article very helpful in re-configuring the WiFi:
https://software.intel.com/en-us/connecting-your-intel-edison-board-using-wifi

Basically running:

configure_edison --wifi

And it brings up a wizard.

onward....


Did I just Brick it??!?

In my quest to get an LED blinking using the Sparkfun GPIO Block (link here), I ran some example code (link here) in eclipse.

And let's just say I didn't use a resistor with my LED...hey it's just one LED right?

Well the blinking didn't occur the way I was expecting... but then again the pin numbering is a bit confusing.

I'll Paste the full pin numbering at the end of this post.

Long story short (no pun intended), I can no longer ping the Edison at the assigned static IP address.

What am I to do? Well I eventually went to the Serial Fall back, which was the first way I was able to ssh into the Edison.

How I did that:
1) With a micro-usb cable connected to the "console" port on the Sparkfun GPIO Block connected to my computer.
2) Went into Device Manager on my PC, then expanded "Ports" and read the COM# of the "USB Serial Port"... you'll know its the correct one for the Edison becasue it wont be present when the Edison isn't plugged in. Screen shot:
3) Fire up the application putty... if you don't already have it you can download it here

4) Select the "Serial" option, type COM# where # is the number you read from Device Manager->Ports
5) Change the Baud rate to 115200 from the default of 9600. Screen shot:




6) When that's all set, click "Open". You should be greeted with a login screen:



----------------------------------------------------------------------------------------------

Ok so I didn't brick it... That's a good thing.Why can't I see it on the network anymore??
It seems the IP address changed from what I had set as static previously, and its in an IP scheme that wont work on my LAN.

But why did the IP address change? According to the "/etc/wpa_supplicant/wpa_cli-actions.sh" file, the reason it's got this new funky IP is:

if [ "$CMD" = "P2P-GROUP-STARTED" ]; then
    GIFNAME=$3
    if [ "$4" = "GO" ]; then
        kill_daemon udhcpc /var/run/udhcpc-$GIFNAME.pid
        ifconfig $GIFNAME 192.168.42.1 up
        cp /etc/wpa_supplicant/udhcpd-p2p.conf /etc/wpa_supplicant/udhcpd-p2p-i$
        sed -i "s/INTERFACE/$GIFNAME/" /etc/wpa_supplicant/udhcpd-p2p-itf.conf
        udhcpd /etc/wpa_supplicant/udhcpd-p2p-itf.conf
    fi




... So unless I fried it and made it do something strange... It seems I've switched the WiFi mode to P2P??
I need to do more investigating ... I'll update when I get that LED Blinking :D

Also the pic reference I mentioned earlier in this post:


Edison Pin (Linux) Arduino Breakout Mini Breakout MRAA Number Pinmode0 Pinmode1 Pinmode2
GP12 3 J18-7 20 GPIO-12 PWM0
GP13 5 J18-1 14 GPIO-13 PWM1
GP14 A4 J19-9 36 GPIO-14
GP15 J20-7 48 GPIO-15
GP19 J18-6 19 GPIO-19 I2C-1-SCL
GP20 J17-8 7 GPIO-20 I2C-1-SDA
GP27 J17-7 6 GPIO-27 I2C-6-SCL
GP28 J17-9 8 GPIO-28 I2C-6-SDA
GP40 13 J19-10 37 GPIO-40 SSP2_CLK
GP41 10 J20-10 51 GPIO-41 SSP2_FS
GP42 12 J20-9 50 GPIO-42 SSP2_RXD
GP43 11 J19-11 38 GPIO-43 SSP2_TXD
GP44 A0 J19-4 31 GPIO-44
GP45 A1 J20-4 45 GPIO-45
GP46 A2 J19-5 32 GPIO-46
GP47 A3 J20-5 46 GPIO-47
GP48 7 J19-6 33 GPIO-48
GP49 8 J20-6 47 GPIO-49
GP77 J19-12 39 GPIO-77 SD
GP78 J20-11 52 GPIO-78 SD
GP79 J20-12 53 GPIO-79 SD
GP80 J20-13 54 GPIO-80 SD
GP81 J20-14 55 GPIO-81 SD
GP82 J19-13 40 GPIO-82 SD
GP83 J19-14 41 GPIO-83 SD
GP84 J20-8 49 GPIO-84 SD
GP109 J17-11 10 GPIO-109 SPI-5-SCK
GP110 J18-10 23 GPIO-110 SPI-5-CS0
GP111 J17-10 9 GPIO-111 SPI-5-CS1
GP114 J18-11 24 GPIO-114 SPI-5-MISO
GP115 J17-12 11 GPIO-115 SPI-5-MOSI
GP128 2 J17-14 13 GPIO-128 UART-1-CTS
GP129 4 J18-12 25 GPIO-129 UART-1-RTS
GP130 0 J18-13 26 GPIO-130 UART-1-RX
GP131 1 J19-8 35 GPIO-131 UART-1-TX
GP134 J20-3 44
GP135 J17-5 4 GPIO-135 UART
GP165 A5 J18-2 15 GPIO-165
GP182 6 J17-1 0 GPIO-182 PWM2
GP183 9 J18-8 21 GPIO-183 PWM3

Feb 6, 2016

Setting a Static IP

I wanted to set the IP to be static.
I found this info on how to achieve that simply and it works great:

(*** Please Read Below for Correction***)

Edit the "/etc/wpa_supplicant/wpa_cli-actions.sh" file:

if [ "$CMD" = "CONNECTED" ]; then

    kill_daemon udhcpc /var/run/udhcpc-$IFNAME.pid

#   udhcpc -i $IFNAME -p /var/run/udhcpc-$IFNAME.pid -S

    ifconfig $IFNAME 192.168.200.200 netmask 255.255.255.0

fi

Add the "#" to comment out the DHCP Config, and then add the line below with the Static Config that you'd like for your Edison setup.

Editing this file is why I installed nano on the Edison instead of using Vi.

PS.... I did discover that I can not ping outside of my local network currently.
Will investigate this but believe the issue is related to some firewall config on the Edison.
till then....

AHA! Nothing to do with any firewall.
As it turns out I needed to add one additional line to the config file above in order to set a default gateway.
Here is the complete section from that file now ("/etc/wpa_supplicant/wpa_cli-actions.sh"):

if [ "$CMD" = "CONNECTED" ]; then

    kill_daemon udhcpc /var/run/udhcpc-$IFNAME.pid

#   udhcpc -i $IFNAME -p /var/run/udhcpc-$IFNAME.pid -S

    ifconfig $IFNAME 192.168.200.200 netmask 255.255.255.0
    route add default gw 192.168.1.1 $IFNAME

fi
Next....

VI... It's just not for me

I'm using putty to SSH into the Edison.
In order to set a static IP address I need to edit some config files.

I don't like VI... so I came across a very simple way to install nano on the Edison:

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 

The above code worked for me immediately.
Enjoy! 

IDE....IDK

My quest for Hello World!!

Well the first thing that came to mind when I received the Edison was its tiny size.. I mean really its tiny considering its basically a full fledged PC.

But I wanted to get going immediately. I understand that Intel is trying to grasp at the established maker community by incorporating Arduino boards and programming etc, but in my mind that would negate the value of what the Edison is.

Well... it seems you can write code for the Edison in multiple IDEs... Intel has Several to choose from..

So Far I've Downloaded:
Intel XDK and Eclipse

I have no idea which is better for what I want right now, or which is better for long term development.\

Looks like I'll have to just play with both and figure it out.

Who thought making an LED Blink could be so time consuming.....