Hackaday Belgrade 2018 is this weekend 26th of May. Get ready for Retro Computing BASIC badge hacking.

2018-belgrade-badge-featured

This weekend 26th of May Hackaday will have their second conference in Belgrade.

You can see the program here.

The conference badge is cool retro computer running BASIC. There will be badge hacking workshop so we will get with us some PIC-KIT3s .

I will have talk about how we hacked Soldering robot with ugly programming interface with TERES-I laptop and FPGA / Sigrok and how we replaced the soldering robot brain with OLinuXino-MICRO, so now it’s ready to take CAD CNC files and use fiducials and do AOI inspection after soldering.

 

FOSDEM 2016 was last weekend with lot of interesting meetings and talks!

FSDM

FOSDEM 2016 was last weekend in Bruxelles! Biggest event in EU this year had a bit less visitors, probably feared by the terrorist news which all TVs are exposing us.

Belgians seems to take this threat seriously as we have seen lot of peoples with automatic guns in military uniforms walking around the city center, but fortunately at FOSDEM we didn’t saw any, neither someone has stop us to check or whatsoever while we have been waling in the city.

Some 8000 different MACs were logged on WiFi infrastructure, so I guess at least 5000 visitors were there.

The picture above shows my captures from the event, buying t-shirt was my way to say thanks to these projects which we use daily both at home and office!

fs

You know you have been at FOSDEM Friday beer party when you wake up next morning and you see (hopefully not permanent) “IloveFS” tattoo on your arm. Here is how the Delirium beer hub was looking like at Friday:

delirium

I had lecture about our experience designing A64 board with KiCAD, Riku Voipio took picture of the tail to enter the room and posted on G+

fsdem

The slides are posted at Slideshare. TL-DR; KiCAD now is solid enough to build complex designs, what we need is little bit of twist to make it even more easy to use and few minor bugs are to be wiped, but overal there is significant progress for one year!

To my surprise KiCAD team emailed me next day and we had a quick meeting with notes they took on all issues I mention on the talk! It’s nice to see such commitement to make the product better!

fosdem2

Another interesting talk in same EDA room was from Clifford who reverse engineered the iCE40 bitstream and made completely FOSS FPGA toolset, which can be used to generate iCE40 based FPGA projects.

I had eye on iCE40 since Antti Lukats posted on Hackaday about his project, but we were quite busy with many other things to may play with it, now we start working on our own ICE40HX1K development board with UEXT for programming by OLinuXino and different extension connectors. The idea is to make entry level board for people who want to make their first steps in FPGA, running Clifford’s toolchain on OLinuXino with this FPGA board connected to it and with different front-end modules like high speed ADCs to make DSO or programmable level shifter 1.2-5.5V which to allow logic analyzer working on different voltage levels, LEDs, buzzers, counters, buttons with tons of examples. I already shoot Clifford e-mail about our plans and looking forward to hear his suggestions as he already have lot of experience with these FPGAs.

Clifford’s work sparkled such interest for iCE40 that now the Lattice demo boards are with 21 weeks delivery time, plenty of time for us to release our own board :))))

fosdem3
Another interesting lecture was about the Rad1o badge for CCC. It was fun to learn for all the difficulties which the development team had to make these happen (including mistakes in the documentation which made them to drill back side of BGA PCB to disconnect solder ball) – they said they would never go through the manufacturing hell again as this production caused them gray hairs although the interest about this badge continues.

Being busy all day long with both design and manufacturing, once I made analogy about the path to design board and then to run this board in production -> it’s like the process to make kid and then to rise it, teach it, make it human being. First job (design) brings just fun, joy and satisfaction, the second is not less interesting but dealing with all manufacturing bugs and troubleshooting the processes is kinda routeen and sometimes even boring :))) but neverthless must be done! Sure we enjoy more designing than manufacturing, but can’t run sustainable business without latter.

HACKING DuinoMite BASIC

Image

There is FIRMWARE WISHLIST on Ken Segler Designs forum and I post there a lot with requests for this or that command to be add 🙂

As the DM-BASIC code is over 30 000 lines I never looked at it in detail, just if wanted to see how some command works I was looking at the specific code which implements it.

Overall I though it’s difficult and confusing to touch in so big code as I could easily mess up something with the other commands.

Iggy from KSD forum did some commands recently for me and when he submited them to Ken to include in the mainstream code I was amazed how simple was to add command to DM-BASIC.

For instance he implemented function DM.VMEM which returns the first address of the video RAM as Nick requested on TBS forum, the code insertion was:

in graphics.h there is one line to add:

// Ingmar
{ “DM.VMEM”, T_FNA | T_NBR, 0, fun_vmem },

this row define the name of the new statement: “DM.VMEM” then define it as FUNCTION returning NUMBER and will call fun_vmem() to get it’s value

and in graphics.c there is this code snip to add:

/////////////////////////////////////////////
// Returns lower 16 bits of video buffer.
// This assumes the upper 16 bits always start 0xa000, maybe we should return all 32 bits?
/////////////////////////////////////////////
void fun_vmem(void) {
int vmem = (int)VA;

vmem &= 0x0000ffff;
fret = (float)vmem;
}

so with adding 5 lines of code we already have new DM.VMEM function which returns the address of the Video buffer!

WOW! I didn’t expect it to be SO easy!

now let’s see how he implemented SHIFTOUT:

first define it in external.h
// Ingmar
{ “SHIFTOUT”, T_CMD, 0, cmd_shiftout },

this time this is COMMAND i.e. do not return value and the code is at cmd_shiftout()

and the code is put in external.c

///////////////////////////////////////////////
// This is invoked as a command (ie, shiftout(Dpin, Clkpin, Mode, OutStr, NumBits) )
// Remember that the string returned in outstr will have the length in byte 0, outstr[0]

#define uDly(a) {WriteCoreTimer(0); while(ReadCoreTimer() < a);}

void cmd_shiftout(void) {
int dpin, cpin, mode, nbits;
int ix, iy; // loop counter
int cnt; // number of bytes to output.
unsigned char mybyte;

char * outstr;

const int BDLY = 3; // Determines clocking rate. # of CoreTimer cycles.

getargs(&cmdline, 9, “,”); // Get the arguments, we should have five, comma seperated.

if (argc < 9) error(“Invalid syntax”); // Test number of arguments given.

dpin = getinteger(argv[0]); // Data pin
cpin = getinteger(argv[2]); // Clock pin
mode = getinteger(argv[4]); // Mode
outstr = getstring(argv[6]); // String to clock out,treated as an array of bytes.
nbits = getinteger(argv[8]); // Number of bits to clock out

if (nbits < 1 || nbits > (outstr[0] * 8)) error(“Too many/few bits”);

if (dpin < 0 || dpin > NBRPINS || cpin < 0 || cpin > NBRPINS) error(“Invalid pin number”);
if (ExtCurrentConfig[dpin] >= EXT_COM_RESERVED || ExtCurrentConfig[cpin] >= EXT_COM_RESERVED) error(“Pin is allocated to a communications function”);

// At this point we should have a valid number of arguments and some possibly valid IO pins.

cnt = (nbits – 1) / 8; // Tells us who many complete bytes to loop over.
cnt++; // at least one byte even if it is a partial byte.

ExtSet(cpin,0); // CLK pin low
uDly(BDLY);

if (mode == 0) { // shift bits out LSB first starting at the END of the string.

for (ix=0; ix<nbits; ix++) { // loop through all bits
iy = ix / 8; // byte offset

mybyte = outstr[outstr[0]-iy]; // current byte being output

if (mybyte & (1 << (ix & 0x07))) {
ExtSet(dpin,1); // output a 1
} else {
ExtSet(dpin,0);
}

uDly(BDLY);
ExtSet(cpin,1); // CLK high
uDly(BDLY);
ExtSet(cpin,0); // CLK low
uDly(BDLY);

} // next bit

} else { // shift bits out MSB first starting at the BEGINNING of the string.

for (ix=0; ix<nbits; ix++) { // loop through all bits
iy = (ix / 8) + 1; // byte offset

mybyte = outstr[iy]; // current byte being output

if (mybyte & (128 >> (ix & 0x07))) {
ExtSet(dpin,1); // output a 1
} else {
ExtSet(dpin,0);
}

uDly(BDLY);
ExtSet(cpin,1); // CLK high
uDly(BDLY);
ExtSet(cpin,0); // CLK low
uDly(BDLY);

} // next bit
}

}

/**********************************************/

the code above is well commented and do not need my comments, again it was very simple to add!

Now let’s hack a bit! I wanted to make my own command to prove the concept!

If you want to do the same:

First you have to obtain the tools to compile DM sources from Microchip web

Download MPLAB 8.80 (166MB) and PIC C32 compiler v1.11b (73 MB) and install them

Then download DM-BASIC latest sources from Olimex Web page http://www.olimex.com/dev/

Unpack them in working directory and try the project. Note I had to setup the C32 locations manually and to change search path for Olimex.h to build the project successfully. The HEX is compiled and located in OUTPUT directory and named OLIMEX.HEX, use the Bootloader tool to burn in DuinoMite.

I compiled the source first and downloaded to DuinoMite. Everything works OK!

OK then let me try to add HELLO command which writes “Hello World” on the screen

I add in misc.h this line which defines my command:

{ “HELLO”, T_CMD, 0, cmd_hello },

and in misc.c the code to be executed when HELLO is met in BASIC:

void cmd_hello(void) {

MMPrintString(“Hello world!\r\n”);
}

Now let’s compile everything and bootload and try!

Image
it works!

So using this approach you can define ANYTHING you want to have in DM but you miss it, only you should have some basic C knowledge, then to be not afraid of learning new stuff and hacking.

I will personally try to implement next: RCTIME command which will measure capacitance on the GPIO pin in the next days and post the result.

This way you can build your own version of DM-BASIC which to add specific functionallity which is not possible to be done otherwise in pure BASIC. Do not forget DM-BASIC is open source project with GPL 3.0 licensee so whatever you do do not forget to make your sources also available, so the community can benefit from your contribution and the project move forward!

Happy hacking!