Sunday, November 12, 2017

Transferring file through serial console (beaglone black)

I recently got myself a beaglebone black. It is self suffice with one board and one usb cable.

However, I find myself struggling to transfer program from PC to beaglebone.

So, I am finding a way to transfer using serial console as my test program is small, I can work with slow transferring speed.

My serial console software is Kitty, which is forked from Putty. Kitty has same interface as Putty, just more convenient to use.

At the Beaglebone side, you will need to install lrzsz: free x/y/zmodem.
Download lrzsz-0.12.20.tar.gz and untar it at Beaglebone.
Then, just simple make the file.

Now to the Kitty link, there is a tutorial which teach how to active zmodem.
First, find this file "kitty.ini file" and activate following:
zmodem=yes

Second, you have to download the sz.exe and rz.exe binaries here.
and set it at kitty program.

This is for rz.exe, but it is same for sz.exe.

Now, we are good to go.
How To Transfer from PC to Beaglebone:
At beaglebone side, type "lrz"
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
root@beaglebone:~/softwares/lrzsz-0.12.20# lrz
▒**B0100000023be50eive.**B0100000023be50
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
then at the kitty icon, click it, choose Zmodem Upload, and select a file.

There is no indication during transfer, so be patient.

Let try the other way around:
How To Transfer from Beaglebone to PC (Not suggesting to do so):
At beaglebone side, type "lrz filename"
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
root@beaglebone:~/softwares/lrzsz-0.12.20# lsz INSTALL
Receiving: INSTALL
Bytes received:   10254/  10254   BPS:20508
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
I am facing some hanging issues after that. I have to restart the system.










Tuesday, October 17, 2017

Review of PIC Based Arduino Form Factor Kit (CIKU)

I am using SK40C to do my hobby project but this development board had consumed the essential pins of PIC18f4550 for I2C and SPI. I dont want to modify the board so I planned to redesign the board.

Nevertheless, I was so occupied with work and I was just starting with KICAD (yea, I am letting go EAGLE). I had the finished product but I wasn't confident enough to send the board for manufacturing. I had several failed attempts in producing a workable PCB (need to try a few version before got the working one).

Until the last cytron sales, I finally get a cytron "PIC based Arduino form factor Kit" at 50 percents discount. It is simple and should be able to perform the SPI/I2C communication wanted. Best of all, cytron still reserve some space for the PICKIT, which is a good news, I can still use the debugger and programmer function. 

First look, it comes with a good looking packing.


From the front view, it is nice small form factor. I like the function where the board can be powered using USB port, save the cabling and skip the power supply. 

Only one button but enough for my use.
I also like the way, cytron categories the power pin, I2C pin, uart pin, ADC pin, PWM pin etc.
However, no crystal, WHY, think I have to live with that.
Note: I have to recalculate all the delays, timing, clock divisor, timer settings.

I like the printing on top the IC. Serve little purpose as the track is routed to fit the Arduino kits. Please aware, the IC pin description has no purpose at all aside of looking nice.

Back side: The track is actually quit messy. Good side: All connector pins are labeled.


Next, I soldered the pin for PICKIT2.
the PICKIT2 fit nicely with the PIC18f and the board still not overturn. Not sure how after I connect the USB cable.



From the software side, I not going to use the custom bootloader so I going to reprogram the whole thing.

Now have a look at the schematic, led at pin RD7, so I did a simple light a led.

Now to reprogram back the bootloader. Where to find one?
microchip official has one: link
openlab: link (seem interesting) let has a try.

Download the source code from github.
at the main folder i found this "MCHPUSB Bootloader PIC18F4550 Family.hex".

Opening my trust worthy pickit2 program, program the hex file.
Following the "easy to follow" tutorials: link
They are so thorough.

I need to add offset for my program, which I dont want to do that, so I going to stop here. However the tutorial provided is teaching how to add offset to your program, you guys are free to try.

Conclusion:
3.5/5 - mostly because I get this for 50 percent discount.
Cytron is a hardware company and it is a good idea that they provide same form factor as Arduino. Althought, they tried to write the library for ciku but we have Arduino for that. I am prefering they  had written the library in C for C18 or XC8 instead of Arduino style.

My 2 cents:
If the library is in C, user can go and read then decide to pass what parameters to funtion. Or learn to change the library source code.
For new beginner, Arduino is good, but as you want to advancing, many people failed.
For my case, I saw most Arduino user unable to switch the role from user to developer. They took the software for granted. They able to do a lot of fancy stuffs but they have no fundamentals and cant even read & set a register. Even simple wiring, placing resistor and capacitors are hard for them as they dont know how to read the datasheet (Arduino modules settled all).

For manager who are going to hire Arduino expert, please hire the one that wrote the library, instead of the one who use the library. It is a two different level of difficulty.


Saturday, May 20, 2017

PIC18f Development Kit Design using KICAD - step 1. schematic

I never thought that I would go back to KICAD. Recently I am making my own mini lab tool using cytron development kits (SK40C), the tool is a combination of PWM genenator, ADC readings, I2C and SPI communication device. During the SPI firmware development, I notice my SPI pin had been used as button. 

RB0 and RB1 are used by I2C communication as well. It is such as waste that rich peripheral pins are used as button.

To continue with my development and my mini lab tool project, I decided to draw a new design which can serve as development kits and fit in well for my mini lab tool.

I started with DIPTRACE, it has annoying little bugs like "I couldnt connect net wire to pin unless I had placed my cursors at certain position". I tried endless time zooming in and zooming out, just to get the correct position.

I gave up.

I open KICAD, look for the component I wanted (PIC18f4553/PIC18f4550) and it is right over there. Other just normal components which can be replaced with similar footprint.

All right, give it a second try.

So much functionality of KICAD that I left out in the first review. Maybe I should post a second review on KICAD.

This is my overall schematic.


























I want to fully utilized all the functions available, but nothing is perfect. In the end, I decided to gave up the SPP (streaming parallel port). I have no idea what it does.

I want 4 ADC pins
I want to ground the unused pin to avoid floating reading.

I2C communication is crucial

Then, I have one more for SPI communication

Since both pins are shared between I2C and SPI, I use jumper for selection.

The third selection is for UART communication.

I want to make the UART communication is pin compatible with Adafruit FT232H Breakout. That why I have so many unconnected pins.

Also, one of the important peripheral is USB.


My LCD 16x2 display
For lcd 16x2 pin, I use all the SPP pins and only use 4 pins for communication.
This is the pins I used.

For the rest of the pins, I make the rest as GPIO.

Not to forget the PICKIT programming pin

I add Vref to get accurate ADC reading

MCU

Hopefully, I get the connection correct. Sending to PCB prototyping is expensive and time dragging.
Next, is choosing the correct component, next blog.

Download Link:
Colour, black-white.

Sunday, April 16, 2017

KICAD first visit (Replacement for eagle cadsoft)

I had been using eagle for quit some years, on and off, been using that for my hobby design. I had tried diptrace before, relatively easier to use, better licensing for hobbyist (lower restriction), but I dont like the schematic interface so I switched to eagle.

Maybe I was influenced by the sparkfun sharing of design, so I felt eagle schematic is the best.

The learning curve for eagle is much stiffer but with the available tutorials in sparkfun, i was able to pickup faster and cope with all eagle dos era less gui intuitive drawing practise.

I may have to put sparkfun tutorial side by side when drawing pcb but it get the job done.

Eagle has encountered a big change in the licensing recently and I think it is a right time for me to change to another pcb designer. Previously, I enjoy the free component library from element14 where i dont need to redraw the footprint or I just did simple modification on existing footprint. Not to mention, the open source component library from sparkfun. 

Now, Eagle has become more expensive and with same pricing, there is an better alternative (diptrace). 

I am struggling between diptrace and kicad. Diptrace is definitely better option with easy to use GUI but KICAD is free.

No one argue with free.

The first thing that change my mind about kicad is the blog written by rocket scream, "From Diptrace to KiCad – Rocket Scream". I like the rocket scream design and they can use it for commercial usage, why can't the normal user use it for hobby.

I decided to design a development kits for dspic,

First, file -> new project -> new project, save it up and you will see the schematic and pcb file.

Open the schematic file, go to file->page settings, key in the information you want

it will shows up in the schematic there,


Open the schematic file, go to Preferences -> component libraries ->

Select the microchip_dspic33dsc.
Then start drawing.

The interface is better than Eagle cadsoft, and easier to use once you familiar with it.
if you want to move components, move the mouse arrow to the component and press "M",
if you want to copy components, move the mouse arrow to the component and press "C",
if you want to rotate components, move the mouse arrow to the component and press "R",
if you want to delete components, move the mouse arrow to the component and press "delete",

This is the 4 functions that I found useful (so far).

 For add components, you click at the icon, then go to the schematic and click on the page again. the component library selection will come up, click to select your component or you can use the filter box to filter out the component you want.


After you finished up with drawing, go to tool-> electrical rules checker, I am using the default function. I just check the not connected net. Other errors, I let it be.

One of my favourite thing to do after drawing the schematic is to convert it to pcb, go to file->plot->plot

Select your output directory, which is your project folder, then click "Plot Current Page". The pdf is stored at your project folder.

From here, I started to follow the tutorial (C:/Program Files/KiCad/share/doc/kicad/help/en/getting_started_in_kicad.html#bus-connections-in-kicad) and intensive googling.

Next, we have link the component with pcb footprint. Click on the generate netlist, click on the "generate" button and save it.
Now click on the Run Cvpcb icon on the top toolbar

You will encounter a lot errors, just click all the way through.
Go to Preferences->footprint library, change KIGITHUB path segment to this:

Note: still had error after setting this, but it get the jobs done.

After that, your components to footprint linking will show up,

Centre is your components and the right side is where you choose your footprint.
One of the handy function of kicad is that you can click on the icon (as following) for a preview of the current footprint,

Select the one of the footprint at right side, then click on

you can see the footprint you had chosen. Actually, Eagle also has similar function but Kicad shows a larger and more precise version of footprint.

Furthermore, you can use the filtering option to checkout the footprint you want.

One thing about the thing that I like about the footprint is Kicad actually provided footprint for hand soldering. It is a very good for prototyping, as I still remembered that I had used reflow soldering's footprint for my current sensor module and it was disastrous, the pad size is almost the same as tip of components. Basically, there is no place on pad that can fit in solder tip to heat up the pad. I ended up giving up that design.

Then go to the kicad pcb, this is something I had arranged and finished half way,

At the pcb side, there are some handy reminders,
- when draw the track, press "v" to create a via.
- if you track cannot be connected, that mean you are violating the design rules.

Go to the tab Design Rules->Design Rules

Go to Net Class Editor and create your own rules,
I set the default track width to 0.3mm, and 0.4mm for power.

Also, I like to disable the ratsnest, because it is confusing for me, you can disable / enable it at here


You can also go to "show / hide the layers manager toolbar" and select the layer you want to see.

For usually work, I will leave this all on, and close the render layers such as following,

I think basically that all, I didn't explore further.

I changed my mind, I will try diptrace for my next project due to reasons below:
- pcb design is my hobby, for hobby, I wish to have something easy to use and fast. Kicad does not fit into this criteria. Usually day work is already headache, I do not coming back, facing another headache piece of software. (turnout kicad is more user friendly, I like the kicad hotkey)
- I could not spend a lot of time on pcb drawing, so I want something that let me finish the design during my free time (like half an hour every day and continue for one week). (diptrace wasnt equal to fast)
- I am not thinking about selling the product, so diptrace licensing is more suitable for me right now. I will come back to kicad if I plan to commercialise my design. (since diptrace not equally friendly, I choose kicad)

For the comparison between Eagle and Kicad,
Talking about function wise, kicad definitely has richer functions then Eagle.
But stability wise, Eagle is much better.
User friendly, both are the same (not user friendly), maybe kicad slightly better because kicad has some convenient hotkeys.
Kicad has less library but it had the convenient function that link the schematic components and footprint during the conversion from schematic from pcb, so it will be good for component which has standard footprint.

This is the schematic. But I didnt finished the pcb though.

That all.



Saturday, March 4, 2017

Intel Galileo getting started

Embedded world is gaining much of the popularity over the time, low cost microcontroller kits equipped with on board debugger, open source compiler, open source library with huge fan base, multiple project posted online, easy to use IDE and code writing (Arduino). Even small kids can start their own programming project.

Often time, people also refer embedded system as a complex system with operating system. Depending on the scale of your project, small project can use micrcontroller, medium or large scale project, people started to use microprocessor.

Two of most common embedded operating systems are window ce and linux. Latter is free, powerful, customise-able and open source.

I want to learn more about embedded linux as it has huge market right now. Talent with related skill set is a good career advancement.

ARM dominant the world of embedded linux, especially in hobbyist project. Two of the most popular single board computers are raspberry pi and beaglebone. Raspberry PI is more popular on application side whereas beaglebone is more to linux kernel & driver development.

My target is learning Intel embedded linux, as Intel microprocessor is much complicated and less people is familiar with this weirdo (people from hobbyist world doesnt like it).

 Finally, I get my hand on one Intel Galileo from my friend.

Quick check
one power supply with different type connector,
one galileo


What will you make?
NO idea, let see how.

I connect a serial to usb converter (from ada fruit) to galileo, 
I like the pinout connection, it can directly plug in galileo board, save my effort in finding jumper and connect both together.

Nevertheless, i have to stick some label stickers behind the usb to serial module as when i plug it in galileo it can easily touch metal LAN connector.


Next, my current favourite terminal software, tera-term.

Before that, you need to install FTDI driver, which can be downloaded from here
At tera term side, uart baud rate, set it to 115200.

First time power on, "error" "ASSERT_EFI_ERROR "
Forget to take a picture.

After some googling, found intel forum, "How to Fix a Bricked or Unresponsive Intel® Galileo Board". Recommended re-flash the BIOS firmware. 

However, you need to have a dediprog first. Expensive tool, able to borrow one from lab. Now for the firmware, took me some time to go through intel website. lntel® Galileo Board Software Package. Look for Flash-missingPDAT_Release.

For the connection from galileo to dediprog, I found one detail description at reversatronics blogspot. Save my time reading the schematic. Basically it is SPI communication protocol.

Wow la, 2nd time power on,

 This time is better, at least i can key in input.

More googling, found this post "How to recover after corrupted SPI flash." Also failed.


Going through Intel community, one user (FlexerUwe) has same issue as me at post 27. 
Reply from Intel support "Which .bin file did you use? Can you please provide a link? The bin file needs to be created with the mac address of your board. Please send me a private message with the mac address of your board and I can create one for you."

I gave up for now.
If I able to power up it, I will change my title to intel galileo step by step until success.





Friday, February 17, 2017

Gate driver charging current (tested using FOD3120V)

The basic of gate driver is providing sufficient gate voltage and gate current to turn on power transistor. The magnitude of these characteristics decide the turn on & turn off time of power transistor.

Most of the power transistor data sheet only show the gate voltage (below is taken from IR IGBT - irgs4620dpbf datasheet)
It always show the gate voltage (VGE) needed to drive ICE(A), but gate current is equally important to achieve faster switching.

The gate resistance (Rg) need to be perfectly tuned to get best performance (no overshoot and no undershoot)

Below is the picture for undershoot (from my point of view), the nicer the curve, the longer turn on time.


Then, this is my view of good switching on delay time,

I didn't have a picture for overshoot. Just imagine above picture with higher voltage spike inside the red circle.

Now about the gate driver IC (optocoupler), they always show the high output current capability:
FOD3120 – 2.5A
FOD3150 – 1.0A

Do we really need such high gate current?
Yes, we do need it. Nevertheless, only high inrush current is needed to turn on the gate but no needed (or maybe little current) to maintain the gate ON state. Let me show you guys.


Below is the point I probed,


Results (voltage spike is used to represent charging current:)

You can see that current only went through during turn on and turn off.


Let see the zoom version, charging gate:


Zoom version of discharging gate:


I increases the switching frequency to get nicer view of charging current, 
I am using the FOD3120V but I didn't push max current driving capability as it will increase burden to optocoupler and power supplies. Good on board isolated power supply is expensive.  

Conclusion:
Gate voltage is important for driving the power transistor but gate current is equally important to achieve optimum switching. Gate resistance need to be carefully selected to achieve fast voltage ramp without causing overshot.