Get your pcb project started.

12 Jul 2016

Guys,

I recently designed a circuit board for the Mega which had an ADC on board along with connectors for various modules - LCD, Bluetooth, RTC, WiFi, uSD LAN and I2C - a bit of a swiss army knife of PCB's. Anyhow, all the components are through hole and it takes about half an hour to solder each one. I had them fabricated through a local company but in order to get a good price per board, I needed quite a few and I have sold several on eBay which are being put into various uses.

Now, I'm getting a bit more adventurous and I wanted to try my hand at smd components and I have designed two more boards for a project I am working on. The problem there was that I couldn't afford to have too many boards made and although I just hate the way your computer knows what you have been looking at and keeps offering you more of the same but I found an advert for a company in China who make 10 prototype PCB boards, up to 100mmX100mm for just 10$ - I actually paid more than that per board for the 80X58mm ones I hade made here.

So I thought I'd give them a go and yesterday the boards arrived - they would have been here much sooner only I was away, I can't believe how fast they made them!

So if anyone has any aspirations to make yourselves some pcb's, I would suggest you download the freeware version of Eagle which is fully functional apart from a 100X100mm limitation in board size. Its dead simple to use - or at least I think so. You start with a schematic, add in your components and connect them up with what eagle calls a 'net' When you have finished, you go to the board design where you will see all the components you have added connected with a 'rats nest' of wires. Move them about until you are happy with the placement and tell Eagle to autoroute. I just wish I'd started using Eagle sooner. Oh and the best ting is its libraries. Say you want to design a shield for the Uno or Mega, well there are ready made libraries with all the correct placements of pins etc. I cant tell you how long it took me placing the connectors on my first project before I found Eagle.

Anyhow, once you've made your design, pop along to www.pcbgogo.com/e and get yourself 10 shiny new pcb's to assemble. The people there are really helpful

17 Aug 2016

Hi,

My buddy used eagle and he was not very happy with the results... he perceived for a few months, but in the end he dumped it.

but Kicad, its excellent..

I would strongly recommend anyone interested in starting work in PCB design, to use Kicad.

also,

PCBWAY.com in china is super quick and cheap

21 Aug 2016

Just came to second KiCad and PCBWAY

The only way to get anything as full featured as Altium is to purchase Altium - KiCad is good because it's free but you will find yourself making lots of custom foot prints, manually assigning them to every component, and a few other manual tasks. Having said that, after all the manual labor your going to know your board inside out and be 99% sure it's going to work first time. I use it all the time for hobby projects.

PCBWAY have always gotten excellent service, fast turnaround and quality products. I'm not being paid to say that.

23 Aug 2016

Eagle vs. Kicad. Both are moving targets. Eagle was just purchased by Autodesk. These are the folks that made AutoCAD some years ago and now their latest product is Fusion 360 a 3D CAD/CAM project that is free for small-time users. Interviews with people at Autodesk say they intend to make it easy for people to design PCBs and the rest of the project together in one place. Fusion will drive both 3D printers and CNC machine tools and it will be nice to be able to do a virtual "fit" of assemblies that contain mechanical parts and PCBs all on the same screen. Autodesk is literally a billion dollar company and does have the financial resource to support this kind of further development of Eagle. Per the interview on their short list is to simplify Eagle's incensing keep a free version and likely add more layers to the free version so you can do ground planes at least.

KiCAD for years moved slowly until CERN decided to sponge them and hired developers. It is open source and now is usable. It's problem is still that you have to make most of the components and add them to your own library before you can make anything that uses much more then common parts and being open spouse there is no option to move up to a paid license the offers professional level support.

Eagle is more used in industry but the free version is limited to about 1/2 a eurocard size and two layers. For many uses this is enough but for many others you need four layers. But Kicad is not feature limited

That said. Anyone here old enough to remember using real tape (the black stuff with sticky adhesive) to "tape out" a PCB design? Believe me ANY software is better than making a PCB with tape on a glue grid, photographing to litho film and then exposing copper clad PCB with an englarer developing the photo resist then etching. it took days.

08 Nov 2017

Any problems with customs in the US when importing larger quantities, say 200, from PCBWAY?

09 Nov 2017

dwqf

09 Nov 2017

LAB1.1

  1. include "mbed.h"

DigitalOut myled(LED1);

int main() { while(1) { myled = 1; wait(0.2); myled = 0; wait(0.2); } } LAB1.2

  1. include "mbed.h"

DigitalOut myled(LED1); DigitalOut myled1(LED2); DigitalOut myled2(LED3); DigitalOut myled3(LED4); int main() { while(1) { myled = 1; wait(0.2); myled = 0; wait(0.2); myled1 = 1; wait(0.2); myled1 = 0; wait(0.2); myled2 = 1; wait(0.2); myled2 = 0; wait(0.2); myled3 = 1; wait(0.2); myled3 = 0; wait(0.2); } } ************ 1.Display hexadecimal counting pattern from 0 to 15 by bliking the on board LEDs using BusOut

  1. include "mbed.h" BusOut myleds(LED1, LED2, LED3, LED4); int main() { while(1){ for(i=0;i<16;i++){ myleds = i; wait(0.5); } } }

2.Interface an LED with any GPIO pin

  1. include "mbed.h"

DigitalOut led(p5); int main(){ while(1){ led=1; wait(0.5); led=0; wait(0.5); } }

3. Interface a switch with any GPIO pin on mbed board and display the status of the switch in on board LED.

  1. include "mbed.h" DigitalIn enable(p5); switch as input DigitalOut led(LED1); LED as output int main() { while(1) { if(enable) { led = 1; } } }

4. Read multiple switch values and display the status of the switch in multiple LED. include "mbed.h" DigitalIn enable(p5); DigitalIn enable1(p6) DigitalOut led(LED1); DigitalOut led1(LED2); int main() { while(1) { if(enable) { led = 1; } else if(enable1){ led1= 1; } else if(enable == 1 && enable1==1){ led=1; led1=1; } } } *************** 1) For 50% Duty Cycle: - A. Using for loop: - Code:

  1. include "mbed.h" PwmOut myled(p5); int main() { while(1) { for(float p=0.0f;p<1.0f;p+=0.1f) { myled = p; wait(0.1); }

for(float p=1.0f;p>0.0f;p-=0.1f) { myled = p; wait(0.1); } } }

B. Using Library Functions: - Code: -

  1. include “mbed.h” PwmOut myled(p5); int main(){ myled.period(2.0f); myled.write(0.50f); while(1); } 2) For 75% Duty Cycle: - A. Using For Loop: - Code: -
  2. include "mbed.h" PwmOut myled(p5); int main() { while(1) { for(float p=0.0f;p<3.0f;p+=0.3f) { myled = p; wait(0.1); }

for(float p=1.0f;p>0.0f;p-=0.3f) { myled = p; wait(0.1); } } } B. Using Library Functions: - Code: -

  1. include “mbed.h” PwmOut myled(p5); int main(){ myled.period(2.0f); myled.write(0.50f); while(1); }
    • 4 1) To transmit ‘VIT SENSE’ to serial monitor: - Code:
  2. include "mbed.h"

Serial device(USBTX, USBRX); tx, rx

int main() { device.baud(9600); device.printf("VITSENSE\n"); }

2) To Receive a character and switch on the on board LED:

Code: -

  1. include "mbed.h" DigitalOut led2(LED2); Serial pc(USBTX, USBRX); void callback_ex() { char a=pc.getc(); printf("%c\t", pc.getc()); if(a=='A') led2 = !led2; } int main() { pc.attach(&callback_ex); } 3) To interface a switch and based on the status of the switch display switch on/switch off on serial monitor

Code:

  1. include "mbed.h" DigitalIn s1(p21); Serial device(USBTX, USBRX); tx, rx int main() { int c; c=s1.read(); if(c) { device.printf("Switch On\n"); } else { device.printf("Switch off\n"); } }
    • 5 1) To read the value of the temperature sensor and display the output serially: - Code:
  2. include "mbed.h" AnalogIn temp(p20); Serial device(USBTX, USBRX); tx, rx int main(){ float a,tempC; device.baud(9600);

a=temp.read(); wait(0.5); tempC=(a*3.685503686*100); printf("Temperature : %f\n",tempC); }

2) Reading the temperature sensor and controlling LED w.r.t increase and decrease in temperature: -

Code: -

  1. include "mbed.h" AnalogIn temp(p20); DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); Serial device(USBTX, USBRX); tx, rx int main(){ float a,tempC; device.baud(9600); while(1) { a=temp.read(); wait(1); tempC=(a*3.685503686*100); printf("Temperature : %f\n",tempC); if(tempC<38) { led1=1; led2=0; } else { led1=0; led2=1; } } }

3) Reading two values from two different temperature sensors and displaying them simultaneously: -

Code: -

  1. include "mbed.h" AnalogIn temp1(p20); AnalogIn temp2(p15); Serial device(USBTX, USBRX); tx, rx int main(){ float a,tempC1,b,tempC2; device.baud(9600); a=temp1.read(); b=temp2.read(); tempC1=(a*3.3*100); tempC2=(b*3.3*100); printf("Temperature from sensor 1 : %f\n",tempC1); printf("Temperature from sensor 2 : %f\n",tempC2); }
    • 6 LCD 1) To write the C++ source code to interface 16X2 LCD with ARM mbed board at different GPIO pins. Code:
  1. include "mbed.h"
  2. include "TextLCD.h"

TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD16x2); rs, e, d4-d7

int main() { lcd.printf("nithin\n"); } **************** 7 ADC A. Interface a potentiometer with any GPIO pin and display the output in the onboard LED Code:

  1. include "mbed.h" AnalogIn LM61(p15); Serial pc(USBTX, USBRX); tx, rx DigitalOut P16(p16); DigitalOut P17(p17); DigitalOut P18(p18); DigitalOut P19(p19); DigitalOut P20(p20); DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalOut myled3(LED3); int main() { float tempC, tempF; myled2 = 1; myled1 = 0; myled3 = 0;

while(1) { conversion to degrees C - from sensor output voltage per LM61 data sheet tempC = (((LM61*3.3))*100.0); if (tempC > 32.3) { myled3 = 1; wait(0.2); myled3 = 0; wait(0.2); } if (tempC < 32.3) { myled1 = 1; wait(0.2); myled1 = 0; wait(0.2); } pc.printf("%5.2F C \n\r", tempC);

} } B. Execution time:

Code:

  1. include "mbed.h" Timer t; Serial device(USBTX, USBRX);

int main() { int i, n=5,f=1; t.start(); for(i=1;i<=n;i++) { f=f*i; } device.printf("\n%d",f);

t.stop(); device.printf("\n%f",t.read()); return 0;

} 8) LCD COUNTER 1) Write a C++ source code to display a continuous count variable on LCD.

Code:

  1. include "mbed.h"
  1. include "TextLCD.h"

TextLCD lcd(p15, p14, p17, p18, p19, p20, TextLCD::LCD20x4); rs, e, d4-d7

int main()

{

int count=0;

while(1)

{

count++;

lcd.locate(0,0);

lcd.printf("%d",count);

wait(1);

}

}

Write a CPP source code to display the analog value to the LCD screen.

Code:

  1. include "mbed.h" #include "TextLCD.h"

TextLCD lcd(p15, p14, p17, p18, p19, p20, TextLCD::LCD20x4); rs, e, d4-d7 AnalogIn LM35(p16);

int main()

{

float tempC,a[10],avg; int i;

while(1)

{

avg=0;

for(i=0;i<10;i++)

{

a[i]=LM35.read();

wait(.02);

}

for(i=0;i<10;i++)

{

avg=avg+(a[i]/10);

}

tempC=(avg*3.685503686*100);

lcd.locate(0,0); lcd.printf(" Temp: ");

lcd.printf("%.2f C \n",tempC);

wait(.5);

}

} 9) I2c

  1. include <mbed.h> Serial pc(USBTX, USBRX); I2CSlave slave(p28, p27);

int main() { char buf[20]; char msg[] = "Slave!";

slave.address(0xA0); while (1) { int i = slave.receive(); switch (i) { /*case I2CSlave::ReadAddressed: slave.write(msg, strlen(msg) + 1); Includes null char break;*/

case I2CSlave::WriteGeneral: slave.read(buf, 20); pc.printf("Read : %s\n", buf); break; case I2CSlave::WriteAddressed: slave.read(buf, 20); pc.printf("Read : %s\n", buf); break; } for(int i = 0; i < 20; i++) buf[i] = 0; } } MASTER

  1. include "mbed.h" Serial pc(USBTX, USBRX); I2C i2c(p28, p27); int main() { int address = 0xA0; char c[20]; pc.scanf("%s",&c); i2c.write(address, c, 20); 10 INTERRUPT 1) When the interrupt is activated, by this rising edge, the ISR executes, and LED1 is toggled. This can occur at any time in program execution. The program has effectively one time triggered task, the switching of LED4, and one event-triggered task, the switching of LED1. CODE:
  2. Include "mbed.h" InterruptIn button(p5); DigitalOut led(LED1); DigitalOut flash(LED4); void flip() { led = !led; } int main() { button.rise(&flip); attach the address of the flip function to the rising edge while(1) { wait around, interrupts will interrupt this! flash = !flash; wait(1); } } 1) Use the interrupt library to toggle the LED whenever a Digital input goes high, implementing a debounce counter to avoid multiple interrupts CODE:
  3. include "mbed.h" InterruptIn button(p5); Interrupt on digital pushbutton DigitalOut led(LED1); digital out Timer debounce; define debounce timer void toggle(void); function prototype int main() { while(1) { debounce.start(); button.rise(&toggle); attach the address of the toggle } function to the rising edge } void toggle() { if (debounce.read_ms()>200) only allow toggle if debounce timer led=!led; has passed 200 ms debounce.reset(); restart timer when the toggle is performed }

11) SPI

  1. include "mbed.h" SPISlavedevice(p11, p12, p13, p14); mosi, miso, sclk, ssel Serial pc(USBTX, USBRX); tx, rx int main() { int counter = 1; device.format(8,3); Setup: bit data, high steady state clock, 2nd edge capture device.frequency(1000000); 1MHz int reply = 99; device.reply(reply); Prime SPI with first reply device.reply(reply); Prime SPI with first reply, again pc.printf("======================================================\r\n"); pc.printf("Startup Next reply will be %d\r\n", reply); while (1) { if (device.receive()) { intvalueFromMaster = device.read(); pc.printf("%d Something rxvd, and should have replied with %d\n\r", counter++, reply); device.reply(++reply); Prime SPI with next reply pc.printf(" Received value from Master (%d) Next reply will be %d \r\n", valueFromMaster, reply); } } } Master
  1. include "mbed.h" SPI spi(p5, p6, p7); mosi, miso, sclk DigitalOutchipSelect(p8); Serial pc(USBTX, USBRX); tx, rx int main() { intvalueToSendToSlave = 20; Starting value only, this increments spi.format(8,3); Setup: bit data, high steady state clock, 2nd edge capture spi.frequency(1000000); 1MHz pc.printf("======================================================\r\n"); pc.printf("Press any key to start...\r\n"); pc.getc(); wait for keyboard int counter = 1; while (1) { pc.printf("%d Value to send = %d ", counter++, valueToSendToSlave); chipSelect = 0; Select device intdataFromSlave = spi.write(valueToSendToSlave); chipSelect = 1; Deselect device pc.printf(" returns %d\r\n", dataFromSlave); valueToSendToSlave++; wait(5); Wait for 5 seconds for readability only } } 12 MUTEX THREAD • Creating two threads and running two tasks through them. • Implementation of MUTEX.

Code1:

  1. include "mbed.h"

DigitalOut led1(LED1); DigitalOut led2(LED2); Thread thread;

void led2_thread() { while (true) { led2 = !led2; wait(1); } }

int main() { thread.start(led2_thread);

while (true) { led1 = !led1; wait(0.5); } } Code2:

  1. include "mbed.h"
  2. include "rtos.h"

Mutex stdio_mutex; Thread t2; Thread t3;

void notify(const char* name, int state) { stdio_mutex.lock(); printf("%s: %d\n\r", name, state); stdio_mutex.unlock(); }

void test_thread(void const *args) { while (true) { notify((const char*)args, 0); wait(1); notify((const char*)args, 1); wait(1); } }

int main() { t3.start(callback(test_thread, (void *)"Th 3")); t2.start(callback(test_thread, (void *)"Th 2"));

test_thread((void *)"Th 1"); }