Close
0%
0%

nedoPC-16

Computer family on PIC16 microcontrollers

Public Chat
Similar projects worth following
Starting from
$13.00
TRC has 84 orders / 3reviews
Ships from United States of America
I started playing with PIC16F871 in 2004 and with PIC16F870 in 2009. In 2011 I already designed 3rd revision (v1.2) of PUBLIC DOMAIN board called "nedoCPU-16" that could be used as a brain for a robot or as CPU for nedoPC-16 family of DIY computers...

Board nedoCPU-16 is a processor board and serial adapter connected together - they could be separated if needed (board was designed in 2009-2011 and revised in March 2019):

nedoCPU-16 (older revision) was used in #3niti alpha simulator (integrated in 3niti alpha simu1 board) and also nedoCPU-16 was featured on Dangerous Prototypes blog on 11/29/2011:
http://dangerousprototypes.com/2011/11/29/nedocpu-16-pic16f87x-breakout-board/

For this board I wrote my own bootloader PDBLv1 (Public Domain Boot Loader v1) that allows to read and write program memory, data memory and EEPROM memory using serial interface (by any terminal program on PC). Also I wrote program that flashes HEX-file into PIC16F870 using PDBLv1 terminal commands for writing and verification. All source codes could be downloaded from FILES section of this project.


In this Hackaday project I will document extensions for this board to convert it into computer nedoPC-16 with keyboard, file storage, display etc.

nedo16v1-eagle.zip

Eagle files for nedoCPU-16 and serial interface adapter (designed in 2011 and revised in 2019)

Zip Archive - 305.66 kB - 03/01/2019 at 14:30

Download

pdbl1hex.c

PDBL1HEX v1.2 - C source code of program for Linux, MacOS X and Windows XP that flash HEX-file to PIC16F870 through PDBLv1 serial interface

x-csrc - 10.17 kB - 05/19/2018 at 01:43

Download

PDBLv1-2A2.inc

Program interface to PDBLv1 (built 2A2) for user programs (serial communication and EEPROM functions for example)

inc - 4.53 kB - 05/19/2018 at 01:42

Download

PDBLv1.hex

Public Domain Boot Loader v1 for PIC16F870 - prebuilt HEX file (built 2A2)

x-hex - 7.60 kB - 05/19/2018 at 01:42

Download

PDBLv1.c

Public Domain Boot Loader v1 for PIC16F870 - source code in C

x-csrc - 12.72 kB - 05/19/2018 at 01:41

Download

View all 6 files

  • Servo test

    SHAOS06/04/2018 at 10:49 0 comments

    Here I use cheap servo MG995 - I'm trying impulses 0.5ms, 1.0ms, 1.5ms, 2.0ms and 2.5ms (last one looks like too long for this servo) with total period of 20ms (and repeat every stage for 50 times to make it 1 second):

    On the video you can see nedoCPU-16 board with nedoSerial interface connected to PC through USB-to-Serial adapter (on the left you can see terminal window). Behind there is a lab power supply that shows current and voltage that goes to servo and black power supply on the right gives 13.8V to nedoCPU-16 that has 7805 voltage regulator on-board.

    Source code of the test program (here I heavily use macros from shaos-p16.inc and PDBLv1-2A2.inc):

    	processor pic16f870
    	radix dec
    	include "p16f870.inc"
    	__CONFIG _CP_OFF & _DEBUG_OFF & _WRT_ENABLE_OFF & _CPD_OFF & _LVP_OFF & _PWRTE_ON & _WDT_OFF & _HS_OSC
    	include "shaos-p16.inc"
    	include "PDBLv1-2A2.inc"
    
    temp	equ	0x7E
    
    wait	equ	17
    
    	ORG 0
    	goto Start
    
    	ORG 4
    	retfie
    
    Start:
    	_bank1
    	movlw	b'00000000'
    	movwf	TRISA^0x80
    	_bank0
    	_serial_print_ok
    	_serial_print_nl
    	clrf	PORTA
    	_delay_ms 4,0
    
    loop:
    
    	_serial_send_ '0'
    	_serial_send_ '.'
    	_serial_send_ '5'
    	_serial_print_nl
    	_movlr 50,temp
    loop_0_5:
    	_movlr 0x20,PORTA
    	_delay_us 500
    	_movlr 0x00,PORTA
    	_delay_ms 0,2
    	_delay_us 500
    	_delay_ms 0,wait
    	decfsz	temp,f
    	goto loop_0_5
    
    	_serial_send_ '1'
    	_serial_send_ '.'
    	_serial_send_ '0'
    	_serial_print_nl
    	_movlr 50,temp
    loop_1_0:
    	_movlr 0x20,PORTA
    	_delay_ms 0,1
    	_movlr 0x00,PORTA
    	_delay_ms 0,2
    	_delay_ms 0,wait
    	decfsz	temp,f
    	goto loop_1_0
    
    	_serial_send_ '1'
    	_serial_send_ '.'
    	_serial_send_ '5'
    	_serial_print_nl
    	_movlr 50,temp
    loop_1_5:
    	_movlr 0x20,PORTA
    	_delay_ms 0,1
    	_delay_us 500
    	_movlr 0x00,PORTA
    	_delay_ms 0,1
    	_delay_us 500
    	_delay_ms 0,wait
    	decfsz	temp,f
    	goto loop_1_5
    
    	_serial_send_ '2'
    	_serial_send_ '.'
    	_serial_send_ '0'
    	_serial_print_nl
    	_movlr 50,temp
    loop_2_0:
    	_movlr 0x20,PORTA
    	_delay_ms 0,2
    	_movlr 0x00,PORTA
    	_delay_ms 0,1
    	_delay_ms 0,wait
    	decfsz	temp,f
    	goto loop_2_0
    
    	_serial_send_ '2'
    	_serial_send_ '.'
    	_serial_send_ '5'
    	_serial_print_nl
    	_movlr 50,temp
    loop_2_5:
    	_movlr 0x20,PORTA
    	_delay_ms 0,2
    	_delay_us 500
    	_movlr 0x00,PORTA
    	_delay_us 500
    	_delay_ms 0,wait
    	decfsz	temp,f
    	goto loop_2_5
    
    	goto loop
    
    	END
    

     It works stable only if servo and microcontroller use separate power sources (and common ground of course)...

  • Public Domain Bootloader PDBLv1

    SHAOS06/03/2018 at 21:17 1 comment

    A little more about my "Public Domain Boot Loader" PDBLv1 which source code could be found right here in the file section of this project:

    https://cdn.hackaday.io/files/1584186777755712/PDBLv1.c


    It was written in C programming language in November 2011 to accelerate software development for PIC simulator of #3niti alpha ternary computer that was built around PIC16F870 (that has ability to re-write its own program programmatically from the code onboard). Source code was compiled into HEX by PICC 9.82.9453 lite (free version) under MPLABX IDE beta 7.12 that put all code at the end of available program space of PIC16F870:

    https://cdn.hackaday.io/files/1584186777755712/PDBLv1.hex

    So as you can see it takes space from address 0x2A2 and up (67% of program space - I know, it's a little bit too much) with GOTO 0x2A2 instruction at address 0x000. Bootloader takes control when you press RESET (or power-on your PIC16F870) and immediately after that send multiple ENTER keypresses to serial port with speed 9600 (8 bits, 1 stop bit and no parity) in less than 1 second after that (otherwise it will jump to address 0x001) then it will go in dialog mode with PDBLv1 prompt in your terminal:

    PDBLv1
    >

    Available PDBL commands (all digits A and B below are hexadecimal):

    !AAAA=BBBB - write word BBBB to program memory in address AAAA
    !AAA=BB - write byte BB to data memory in address AAA
    !AA=BB - write byte BB to EEPROM in address AA
    ?AAAA - read one word from program memory with address AAAA
    ?AAA - read one byte from data memory with address AAA
    ?AA - read one byte from EEPROM in address AA
    . - exit from bootloader and jump to address 0x0001

    Possible errors:

    ERR01 - illegal hexadecimal digit was entered
    ERR02 - character '=' is expected
    ERR03 - enter is expected
    ERR04 - attempt to write in protected region (bootloader code)

    User can write words into program memory and then jump to the code by sending dot to the terminal - bootloader will perform GOTO 1 where user should have entry point of user program. Because bootloader has a number of useful subroutines already as writing and reading of EEPROM, sending and receiving bytes from terminal and also initialization of peripherals user program my utilize it by direct calling those subroutines - for this particular built (that I called v1-2A2) actual addresses may be taken from this include file (that also includes useful macros):

    https://cdn.hackaday.io/files/1584186777755712/PDBLv1-2A2.inc

    For example this is interface to EEPROM reading subroutine of PDBLv1:

    eeprom_read             equ     0x0385
    ; ARG:W RET:W USE:#70,#71
    
    _eeprom_read MACRO A,B
            movf    A,w
            call    eeprom_read
            bcf STATUS,RP0
            bcf STATUS,RP1
            movwf   B
            ENDM
    
    _eeprom_read_ MACRO A,B
            movlw   A
            call    eeprom_read
            bcf STATUS,RP0
            bcf STATUS,RP1
            movwf   B
            ENDM
    

    1st macro (_eeprom_read) if argument A is a data register and 2nd macro (_eeprom_read_) if argument A is an actual number (argument B is always data register to store read byte). Also this INC-file lists data registers that PDBLv1 is using and also specify free data registers that user program can use:

    ; COMMON #70..#7D(14) free #7E,#7F
    ; BANK0 #20..#3B(27) free #3C..#6F
    ; BANK1 (0) free #A0..#BF
    

    This knowledge is relevant only if user program uses PDBL subroutines. If not then it could be ignored because PDBL will give full control to user program if nobody invokes bootloader from terminal in the boot time and user program then can use all available data memory.


    In order to simplify process of re-flashing the PIC I wrote a program for Windows/MacOS/Linux that uses PDBL commands and sends HEX program to the PIC word by word (with verification):

    https://cdn.hackaday.io/files/1584186777755712/pdbl1hex.c

    PDBL makes sure that written program occupies only free space between 0x001 and 0x2A1 (and 1st GOTO is moved from address 0x000 to address 0x001 in order to co-exist with bootloader that takes control...

    Read more »

  • nedoCPU-16 PCB/KIT on Tindie

    SHAOS05/21/2018 at 23:14 0 comments

    nedoCPU-16 board (multiple options from PCB to fully tested board with serial interface) is available on Tindie:

    https://www.tindie.com/products/TRC/nedocpu-16/

  • 2011 video of assembling nedoCPU-16

    SHAOS05/19/2018 at 01:53 0 comments

    10x time-lapse soldering of nedoCPU-16 prototype:

View all 4 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates