WeisTek’s Current Build Logs (pinned)

Featured

This post is pinned to make it easier to find the build logs. I will update this post regularly

Announcements

Find this blog useful or interesting? consider supporting me by buying directly from me on my Tindie store, or support me through PCBs.io <- this nets me a small credit every time you purchase one of my designs shared through them.

(Price drops on ParraPortCNC, and Attiny85A dev board. New items and updated stock!, ParraPortCNC A2.2 now in stock!!)

k40 middle man boards with connectirs, now available from my tindie store! 

I sell on Tindie

Current Build Logs

K40 laser build log links have been moved to the temporarily postponed section.

CPLDuino (XC9536XL) Mashup (External)

8bit Avr Tutorials in C using Atmel Studio 7

Gerald chess board 01-01-2017.

External Build log: miniSam-Zero, New serial bootloader for Arm Cortex M0+

20160706_093510

Mini CRT clock

image

Traveling Hacker box’s

20160615_183230

Maintaining old lab equipment

This section is dedicated to posts about old lab equipment.

20160515_132533.jpg

GPS Disciplined (selectable) frequency standard

3020T Chinese CNC router build logs

3020T CNC.

ParraPortCNC 3020T CNC upgrade build logs

Updated rev A2 now in my Tindie store

20160131_143312

External build log: Micro numitron clock

Finished clock added to the hackaday square inch contest.

Finished clock added to the hackaday square inch contest.

NumiClock, VFD, Numitron, Nixies | starting a clock design

NumiClock is ALIVE!

NumiClock is ALIVE!

K40 MiddleMan board files, and links Updated

Custom GameBoy flash cart.

Custom Gameboy flash cart based off of xzakox’s mbc emulated cart design, updated with newer components and re routed for use with oshpark, custom pixel art.

Temporarily postponed build logs

K-40 Laser upgrade and modifications (Arduino/Ramps)

Before

After

image

  1. Part 1
  2. Part 1A
  3. Part 2
  4. Part 3 : Cleanup and a closed loop cooling system.
  5. Laser mis-haps, final post delayed.
  6. Final Post (Cleanup, small changes, middleman files release, FIRE!) <– Delayed
  7. Revival, new frame/enclosure.

Designing an Arduino based alarm clock (pending post).

  1. Part 1 Intro
  2. Part 2 (coming soon, Postponed)

DIY reflow oven (Pending post).

  1. Part 1 (Pending post).

Diy Microcontroller Retrospect + custom robots (awaiting parts, pending post).

Old Build Logs

Rasperry Pi OwnCloud. (Still relevant)

  1. Part 1

Prusa Mendel I2 Build and upgrades. (Super Old)

  1. Part 1: Building the frame.
  2. Part 2: The Brains.
  3. Part 3: Upgrades and stuff. (Pictures are missing, will fix soon.)

PS3 (PC power supply conversion / Reflow) : (Failed).

  1. Part 1

Omnia I900 Custom USB data cable. (Super Old)

  1. Part 1

GB flash cart, Board routing is almost done.

I tend to like to power through designs but this time im forcing myself to take time and think it through.

This where I’m currently at in the design. I still have to assign the 64 pin package all of its nets but I think I can do everything in two layers :)

it’s funny to think that the cartridge will be x times more powerful than the hardware in witch it will sit. but I figured this would be the cheapest way and least component count to get a usb flash cart.

if I can swing it I may add uSD support… well see if I want to punish myself that bad with only two layers.

until next time.

Custom Gameboy Cartridge round 2..

I’ve decided to finish thus project finally. between work etc I have a little time to see if I can bring the project into the new age or more recent age and source readily available parts that don’t cost an arm and a leg.

so far I have the carts at a reasonable BOM price. 

The specs so far are:

  • An MBCx simulated by a CPLD
  • A 32Mbit (4MByte) flash ROM upgradable to 64Mbit.
  • A 1Mbit (128KByte) Flash for non-volatile RAM
  • Bi-Directional Voltage converters for the ROM since the only 5v chip is the RAM.
  • LDO for the rest of the 3.3v logic.

I have also sourced clear green (non official) game boy cartridges to house the PCB.

The schematics are done and all the parts are ordered. I still have to route the board but will soon send for DV2 of the cartridge. 

if I have time or the patience I will try my hand at a bootstrap menu to take advantage of the 32Mbit/64Mbit space to allow for use as a multi cart.

until then. stay happy stay healthy and keep hackin.

8bit uC’s (AVR) USART in C

In this tutorial we are going to get serial communication up and running. Having serial communication helps in that we can send human readable messages to a computer instead of decoding a blinking led, unless that’s your cup of tea go ahead and skip this tutorial :)

Getting started.

We are going to learn about header files as well here as I like to split my code up into files that have meaning, such as uart.h and uart.c having your functions etc in these files makes it easy for you to remember along with good function names where your function is. Incase the need arises to edit or change something in the function.

Adding files to our project.

First we need to add a few files to our project, board.h, uart.h, uart.c. board.h is where we will redefine all of our important pins, our clock, desired serial baud rate etc.

Uart.h and uart.c are going to house all of our important and reusable serial functions. One approach to creating new functions is to use main.c as a prototype area, define your function in main.c and test it out. If all goes well it can go into the library it was meant for.

So right-click on your project name go to add and add new. This will bring up a new window that allows you to pick and name a new file.

atmelstudio5

We will be adding two .h (header files) and one .c file to our project. Go ahead and create the required three files. Your file tree should look like this now.

atmelstudio6

In brief what is a header file? A header file contains the definitions for your desired library, this file is also included in your main program with the

#include

directive. This tells the Atmel studio you want this library and it’s functions compiled into your program. If you try to use a function from a library without including it the compiler will throw all kinds of errors some cryptic and won’t compile your project.

Board.h file contents.

So first we are going to redefine some pins define our clock and desired baud rate. I will comment the code so it’s well explained. I will go into further detail on registers when we do uart.c.

/*
  board.h
  Author OCybress
  Summery used to define easy to. remember names 
  and other board related defines.
*/

#ifndef BOARD_H_
#define BOARD_H_

//this will be used in calculating baud. 
//Its also defined in your compiler settings 
//so this may throw a warning F_CPU redefined.
#define F_CPU 16000000UL

//move led pin definition here
#define LED_PIN PB5

#endif /* BAORDS_H_ */

uart.h header file

the uart header file contains some uart specific re defines and function prototypes, uart_init, uart_write_byte, and uart_read_byte

#ifndef UART_H_
#define UART_H_

//uart related defines
#define UART_DATA_REG UDR0
//port D bit 0, TX (register UDRE0)
#define TX UDRE0
//port D bit 1, RX (register RXC0)
#define RX RXC0

//baudrate can be set to 115200 as well since we are 
//calculating the baud rate based off F_CPU
#define BAUD_RATE 9600

//Calculated baud rate basses on F_CPU
#define BAUD_PRESCALLER ((F_CPU/(BAUD_RATE * 16UL))-1)

//usart baud rate register high byte
#define USART_BAUD_REG_HB UBRROH
//usart baud rate register low byte
#define USART_BAUD_REG_LB UBRR0L
//tx/rx en bits
#define TX_ENABLE TXEN0
#define RX_ENABLE RXEN0

//Uart Control and Status Registers
#define UART_CTRL_STS_REG_A UCSR0A
#define UART_CTRL_STS_REG_B UCSR0B
#define UART_CTRL_STS_REG_C UCSR0C

//critical uart functions
void usart_init (void);

/*********************************/
/*Useful uart function prototypes*/
/*********************************/
uint8_t uart_read_byte();
void uart_write_byte(uint8_t data);

#endif /* UART_H_ */

uart.c

If you wish to use the bare registers instead of the redefined names feel free, it will work the same. Note they are already defined so you do not have to define the register names. For example if you wanted to use UDR0 instead of UART_DATA_REG that will not effect the code in any way. In fact I urge you to use the registers instead of redefining them for the first few times you write your uart functions. Once you are comfortable with the register names then you can rename as you see fit.

#include "board.h"
#include "uart.h"

/*************************/
/*Critical uart functions*/
/*************************/
void usart_init ()
{
    USART_BAUD_REG_HB = (uint8_t(BAUD_PRESCALLER>>8);
    USART_BAUD_REG_LB = (uint8_t)(BAUD_PRESCALLER);
    UART_CTRL_STS_REG_B = (1<<RX_ENABLE )|(1<<TX_ENABLE);
    //Data flow settings.
    //data bits = 8, parity = none, stop bit = 1
    UART_CTRL_STS_REG_C=(3<<ucsz00);
}

/***********************/
/*useful uart functions*/
/***********************/

/*Read one byte to the UDR0 register*/
uint8_t uart_read_byte()
{
	//wait until the port is ready to read.
	while((UART_CTRL_STS_REG_A &(1<<RX))==0){}
	//return received data
	return UART_DATA_REG;
}

/*Write one byte to the UDR0 register*/
void uart_write_byte(uint8_t data)
{
	// wait until the port is ready to write.
	while((UART_CTRL_STS_REG_A & (1<<TX)) == 0){}
	
	//write data to port
	UART_DATA_REG = data;
}


Putting it all together.

Now that we have everything setup, and our uart library is ready to go. Lets get main.c ready to spit some text to our terminal.

#include <avr/io.h>
//include our library files.
#include "boart.h"
#include "uart.h"

//Test message to send over uart.
const char aTestMsg[] = {"hello world"}

//example of a prototype function in main.c to later
//move into uart.c
void uart_write_string(char *s)
{
	unsigned int i=0;
	while(s[i] != 0x00)
	{
		uart_write_byte(s[i++]);
	}
}

void main(void)
{
	/*setup uart for 9600baud*/
	usart_init();
	
	//send byte with uart example Hello World
	uart_write_byte("H");
	uart_write_byte("e");
	uart_write_byte("l");
	uart_write_byte("l");
	uart_write_byte("o");
	uart_write_byte(" ");
	uart_write_byte("W");
	uart_write_byte("o");
	uart_write_byte("r");
	uart_write_byte("l");
	uart_write_byte("d");
	uart_write_byte("\n"); //new line

	//send a string 
	uart_write_string(aTestMsg);
	
	uint8_t u8_data;
	
	//example of sending a string without the array.
	uart_send_string("Send an option, h = hello, x = exit\r\n");
	//uart_read_byte example
	while(u8_data != 'x')
	{
		u8_data = uart_read_byte();
		if(u8_data == 'h')
		{
			uart_write_string("hello\r\n");
		}
		if(u8_data == 'x')
		{
			uart_write_string("Exiting menu.\r\n");
			u8_data = 'x';
		}
	}/* end while */

	uart_write_string("End Example..\r\n");
	
}/* end main */

Once everything is in order. Compile the project and upload it to the avr (atmega328 series), load up a terminal such as cool term and you should be ready to go. Be sure to go to options and set your connection settings to 9600 baud, the rest should be the default settings.

I’ll post a terminal picture soon.

Going forward.
Now that we know how to toggle some bits, and use the uart to extract useful information from our microcontroller. We can do a lot more experimentation and still know whats going on inside the micro if anything goes wrong.

Next time or later on we may look at implementing Uart functions in ASM just for the hell of it 😉

Whats next?
I think the ADC is a good place to start next, as this allows us to input real world data into the micro , such as a 4×3 keyboard, analog sensors etc. Or we may do something with SPI flash… If you have any comments, questions, or corrections feel free to drop a comment or email me.

8bit uC’s (AVR) getting started in C

A Series of Tutorials. (Rather a space to hold my learnings, so i don’t forget them.)

So I’ve meant to make a “tutorial” series for a while on getting started with atmel avr’s. This is not going to be a tutorial on the Arduino ide or their library’s for that matter, however we will be doing these tutorials with the atmega328 uC IC.

Getting started.

So you bought some Atmega328 microcontrollers from some distributor on the internet, now you are wondering what you should do or how to get started with them. Well you have a few options, go download the Arduino IDE which I recommend if you don’t have a stomach for C and working with Avr registers, boot up Linux and setup an AVRGCC environment and do everything that way. What I recommend, since I run windows on most of my rigs aside from servers, is to download Atmel Studio 7. This software will give you just about everything you need to get started programming these avr’s.

You may also want to pick up an Atmel ICE programmer from digi-key as this allows you to program and debug not only Atmel 8bit avr’s but ARM cortex controllers as well. I will not go into detail on how to bread board a bare atmega328 or other uC at this time. You can follow along with these tutorials with an arduino uno, just keep in mind if you program via ICSP such as with the Atmel ICE you will lose your boot loader. You can reflash the boot loader again later through the ICSP header.

Loading a new project

With Atmel studio 7 installed, start the program and let everything load.

Click on new project.

atmelstudio1

Next you will be presented with what type of project you wish to create. Keep the defaults but change the name of the project to something easy to remember and select a directory to save to.

atmelstudio2

Last thing to do before you can start slamming code into your mint new project is to select the uC you will be using. Since we are using the atmega328, that is what I have selected. This screen tells you what programmers are officially supported with the selected device and gives a link to the datasheet.

atmelstudio3

Lets start twiddle some bits.

if it’s not already open, double-click on main.c in the right panel to open your project main file. you can name this file anything but usually it’s a good idea to name it something short and to the point main is a good name.

you will see code in the file already generated for you.

#include <avr/io.h>
int main(void)
{
    /* Replace with your application code */
    while (1)
    {
    }
}

If you pull up a pin out of the uC in question via google you will see that pin 13 (arduino style) is listed as PB5, shown below.
atmega168pinmap2
lets break this down a bit.

PB5 = [PB] the port the pin is connected to internally
[5] is the bit associated with that pin.

We also need to know about a few other registers

DDR[port] eg DDRB for Data Direction Register PortB. Setting this to 1 will set all pins on that port as output, atm we dont want that we only want to set PB5 as an output.

We do that with a bitwise OR operator |, likewise to set as input use a bitwise AND &

Heres how that looks

DDRB |= PB5;

We can make PB5 easier to remember by defining it into a new name. At the top of our code under the

#include

We define this macro

#define LED_PIN PB5

All this define does is say the defined name (LED_PIN) is now PB5, you can still use the name PB5 but this just makes it easier to remember your pins etc.

Also include delay.h at the top.

#include <avr/io.h>
#include <util/delay.h>

So now lets use our newly defined pin name with this code.

//defines uC pin names, ports, etc.
#include <avr/io.h> 
//used for _delay_ms() function
#include <util/delay.h> 		

//redifine pin.
#define LED_PIN PB5 			

//main
int main(void)						
{
   //Set pin as an output
   DDRB |= LED_PIN; 			
   
   //infinite loop
   While (1)					
   {
       //set led pin high
       PORTB |= LED_PIN; 	
       //wait 1s
       _delay_ms (1000);
       //set led pin low
       PORTB &= ~LED_PIN;
       //wait 1s
       _delay_ms (1000); 		
   }
}/*end Main*/

As one would expect this will toggle PB5 every 1 second. This is usfull in that the uC can present usful information to you about what is going on inside. Now at the top of the program click the little green arrow to compile and program without debugging.
atmelstudio4

Now watch as your creation blinks at you mindlessly… Be sure to save your project as we will be using it in the next tutorial as a base.

Whats next?
In the next tutorial we will configure the UART, better known as the Serial port so we can get human readible information from the uC. If you found this tutorial usfull or have questions, feeel free to drop a comment.

Until next time!

Gerald Chess board specs

Wow it’s been a while! Much longer than I had planned. Hope everyone had an awsome Christmas, holiday, what ever way you celebrate. Oh and an epic new year!

Intro:

So what are we building this time? A chess board, yes a chess board. This one is special though, not only is it named after my late grandfather it has some (or will rather) awsome features tapped to it :)

Specs:

  • 1 x atmega328 uC
  • 1 x esp8266 uC (bought bare ICs)
  • 2 x 4Mbit i2c eeprom 24lcxxx series
  • 64 x i2c rgb Leds
  • 64 x hall sensors (mag sensors)
  • 2 x 74hc595 serial to parallel ic
  • 1 x 128×96 oled screen
  • 1 x numeric keypad
  • Power supply, custom chess board etc.

Sudo explination:

The atmega is the brains of the outfit, it will handle chess move calculations, keypad entry, oled display, rgb leds and reading of hall sensors via the 595s configured in a 8×8 matrix.

The esp8266 will handle all things networking. OTA’s for the atmega, itself, and network stuffs.

I don’t want to get into a lot of detail atm, as I am still waiting for parts and working my C foo on the 328.

For now, just know I haven’t gone any where. Just and bit busy.