User avatar
Wizard
Posts: 120
Joined: Sun Aug 19, 2012 4:52 am
Location: Sweden

Re: Raspberry 500 / Amiga Pi ?

Thu Dec 13, 2012 2:45 pm

Altairst8te74 wrote:Can somebody please confirm if this will work at the bios level on a pc? I have been putting this together on a netbook and I could not get into the bios using the amiga keyboard.

I have yet to test it on a proper motherboard.

Thanks :)
This has got nothing to do with the host computer you're connecting the A500 keyboard and Arduino Leonardo (or similar) to.
This is in fact only a "USB keyboard".

Some computers don't load USB driver until after BIOS has executed and those computers need a native/PS2/whatever keyboard to send data during BIOS phase.
Raspberry Pi - finally a worthy replacement for A500!!!

thradtke
Posts: 492
Joined: Wed May 16, 2012 5:16 am
Location: Germany / EL

Re: Raspberry 500 / Amiga Pi ?

Thu Dec 13, 2012 2:51 pm

Altairst8te74 wrote:Can somebody please confirm if this will work at the bios level on a pc? I have been putting this together on a netbook and I could not get into the bios using the amiga keyboard.
You need to power the keyboard some time before the netbook starts. That's due to the Leonardo waiting a couple of seconds before running its firmware. If you did, Wizards comment applies ;-).
Rocket Scientist.

Altairst8te74
Posts: 23
Joined: Mon Nov 19, 2012 10:08 pm

Re: Raspberry 500 / Amiga Pi ?

Thu Dec 13, 2012 6:04 pm

I am not bothered about the netbook, it was just a testbed thing. I really do need to access the bios using this keyboard solution or I am stuck again lol.

I have a Zotac mini-itx board and I am hoping the usb ports are powered in standby mode... well thats my thinking anyway! I have a gigabyte board here that supplied a constant 5v power feed on the usb's.
Is this the right thing? so 5v is going to the leonardo so its already running to the point of when the pc is fired up I can at least get into the bios? If I cant do that then I will be either forced to use a normal keyboard if I ever need to make changes or flit back to the keyrah, something I really dont want to do :(

thradtke
Posts: 492
Joined: Wed May 16, 2012 5:16 am
Location: Germany / EL

Re: Raspberry 500 / Amiga Pi ?

Thu Dec 13, 2012 8:08 pm

There's a chance. You could upload a different bootloader with a shorter delay. Whether it exists or the sources have to be adapted I don't know yet. Try looking for 'leonardo bootloader' on Google and see if you find something in the sources. I will help if necessary. Maybe others too, I know Olaf and Mike have firm knowledge (and more than I have).
Rocket Scientist.

Altairst8te74
Posts: 23
Joined: Mon Nov 19, 2012 10:08 pm

Re: Raspberry 500 / Amiga Pi ?

Thu Dec 13, 2012 8:23 pm

Thanx :)

Is this going in the right direction?
https://github.com/arduino/Arduino/pull/118

thradtke
Posts: 492
Joined: Wed May 16, 2012 5:16 am
Location: Germany / EL

Re: Raspberry 500 / Amiga Pi ?

Fri Dec 14, 2012 6:10 am

Looks good.

OTOH, if you use a standard PC anyway, you could use the Leo to power and shutdown the computer on keypress.
Rocket Scientist.

User avatar
Wizard
Posts: 120
Joined: Sun Aug 19, 2012 4:52 am
Location: Sweden

Re: Raspberry 500 / Amiga Pi ?

Fri Dec 14, 2012 7:04 am

Don't forget that many computers nowadays power USB even if the computer is turned off.
This is certainly the case of all my laptops but then I always put them in hibernate mode... (restarts are for whimps who like to play safe ;) )
Raspberry Pi - finally a worthy replacement for A500!!!

Altairst8te74
Posts: 23
Joined: Mon Nov 19, 2012 10:08 pm

Re: Raspberry 500 / Amiga Pi ?

Mon Dec 17, 2012 2:31 pm

Sorry guys I am a bit gutted with this! I tested olaf's revised sketch and it has now made the keyboard brilliant! It has really sped it up :)

But :(

I just cannot get into the bios using the leonardo... I have a pc here that powers the usb ports in standby mode but the moment I turn off or restart the machine, the leonardo disconnects and will not do anything until windows starts to load, which means it will not respond and allow me into the bios. Apart from that I am really chuffed with it.

chickennuggets
Posts: 6
Joined: Sun Dec 16, 2012 10:28 pm

Re: Raspberry 500 / Amiga Pi ?

Mon Dec 17, 2012 3:50 pm

I'm doing the same, but with something a bit older: An Apple III. Found 2 of them at a dump. There is a whole heck of a lot of space in there for full-height expansion cards. Putting the Pi in there is no problem. The whole chassis is a solid piece of aluminum. It weighs about 20 or so pounds. When I have it completed, I'll post some pictures.

Altairst8te74
Posts: 23
Joined: Mon Nov 19, 2012 10:08 pm

Re: Raspberry 500 / Amiga Pi ?

Mon Dec 17, 2012 7:12 pm

Excellent :) cant wait to see the pictures!

With the bios issue, I guess this is nothing to worry about on the pi board! I may decide to take the leonardo and hook up a c64 keyboard instead. I have a dead c64 breadbin here crying out for a pi mod.

User avatar
olaf
Posts: 11
Joined: Sat Nov 03, 2012 3:01 pm
Location: Germany, Friesland
Contact: Website

Re: Raspberry 500 / Amiga Pi ?

Thu Dec 27, 2012 5:09 pm

Hi,

I made some changes in the sketch:
- IO configuration/ IO read and write without arduino functions
- new functions for keypress, keyrelease and keystroke in the sketch
(this means that the arduino core files don't have to be modified any more)
- caps lock is "real" caps lock now
- num lock is "real" num lock now
- scroll lock added
- AMIGA Key is left WINDOWS Key now (use Help key for special functions)
- Mode Keys are functional without other keys (important for Pinball ;-) )
- code shrinked and speed increased whereever possible

Code: Select all

#define BITMASK_A500CLK 0b00010000    // IO 8
#define BITMASK_A500SP  0b00100000    // IO 9
#define BITMASK_A500RES 0b01000000    // IO 10
#define BITMASK_JOY1    0b10011111    // IO 0..5,7
#define BITMASK_JOY2    0b11110011    // IO A0..A5    
#define SYNCH_HI        0
#define SYNCH_LO        1
#define HANDSHAKE       2
#define READ            3
#define WAIT_LO         4 
#define WAIT_RES        5

KeyReport _keyReport;
uint32_t counter = 0;
uint8_t Joy, MemoJoy1, MemoJoy2, state, bitn, key, fn,keydown, ktab[0x68]={
  // Tilde, 1-9, 0, sz, Accent, backslash, Num 0 (00 - 0F)
  0x35, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x2D, 0x2E, 0x31,    0, 0x62,
  // Q bis +, -, Num 1, Num 2, Num3 (10 - 1F)
  0x14, 0x1A, 0x08, 0x15, 0x17, 0x1C, 0x18, 0x0C, 0x12, 0x13, 0x2F, 0x30, 0   , 0x59, 0x5A, 0x5B,
  // A-#, -, Num 4, Num 5, Num 6 (20 - 2F)
  0x04, 0x16, 0x07, 0x09, 0x0A, 0x0B, 0x0D, 0x0E, 0x0F, 0x33, 0x34, 0x32, 0,    0x5C, 0x5D, 0x5E,
  // <>,Y- -, -, Num . , Num 7, Num 8, Num 9 (30 - 3F)
  0x64, 0x1D, 0x1B, 0x06, 0x19, 0x05, 0x11, 0x10, 0x36, 0x37, 0x38,    0, 0x63, 0x5F, 0x60, 0x61,
  // Space, BS, Tab, Enter, Return, ESC, Del, -, -, -, Num -, -, up, down, right, left (40 - 4F)
  0x2C, 0x2A, 0x2B, 0x58, 0x28, 0x29, 0x4C,    0,    0,    0, 0x56,    0, 0x52, 0x51, 0x4F, 0x50,
  // F1-F10, -, -, Num /, Num *, Num +, - (50 - 5F)
  0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43,    0,    0, 0x54, 0x55, 0x57,    0,
  // modifiers: Shift left, Shift right, -, Win left, Crtl left, Ctrl right, Alt left, Alt right
  0x02, 0x20, 0x00, 0x08, 0x01, 0x10, 0x04, 0x40 
};

void setup() {
  // Joystick 1 (Port D)
  DDRD = ~BITMASK_JOY1; // direction INPUT
  PORTD = BITMASK_JOY1; // activate PULLUP
  
  // Joystick 2 (Port F)
  DDRF = ~BITMASK_JOY2; // direction INPUT
  PORTF = BITMASK_JOY2; // activate PULLUP

  // Keyboard (Port B)
  DDRD = ~(BITMASK_A500CLK | BITMASK_A500SP | BITMASK_A500RES);  // direction INPUT
}


void loop() {
  // Joystick 1
  Joy = ~PIND & BITMASK_JOY1;
  if (Joy != MemoJoy1) {
    HID_SendReport(3, &Joy, 1);
    MemoJoy1 = Joy;
  }  

 // Joystick 2
  Joy = ~PINF & BITMASK_JOY2;
  if (Joy != MemoJoy2) {
    HID_SendReport(4, &Joy, 1);
    MemoJoy2 = Joy;
  }  
  
  // Keyboard
    if (((PINB & BITMASK_A500RES)==0) && state!=WAIT_RES) {   // Reset
    interrupts();
    keystroke(0x4C,05);        // CTRL+ALT+DEL
    fn=0;
    state=WAIT_RES;
  }
  
  else if (state==WAIT_RES) {   // Waiting for reset end
    if ((PINB & BITMASK_A500RES)!=0) state=SYNCH_HI;
  }
  
  else if (state==SYNCH_HI) {   // Sync-Pulse HI
    if ((PINB & BITMASK_A500CLK)==0) state=SYNCH_LO;
  }

  else if (state==SYNCH_LO) {   // Sync-Pulse LOW
    if ((PINB & BITMASK_A500CLK)!=0) state=HANDSHAKE;
  }
 
  else if (state==HANDSHAKE) {  // Handshake
    if (counter==0) {
      DDRB |= BITMASK_A500SP;   // set IO direction to OUTPUT
      PORTB &= ~BITMASK_A500SP; // set OUTPUT to LOW
      counter=millis();
    }
    else if (millis()-counter>10) {
      counter=0;
      DDRB &= ~BITMASK_A500SP;   // set IO direction to INPUT
      state=WAIT_LO;
      key=0;
      bitn=7;
    }
  }
  
  else if (state==READ) {        // read key message (8 bits)
    if ((PINB & BITMASK_A500CLK)!=0) {  
      if (bitn--){
        key+=((PINB & BITMASK_A500SP)==0)<<(bitn); // key code (add bits 0...6)
        state=WAIT_LO;
      }
      else {  // read last bit (key down)    
        keydown=((PINB & BITMASK_A500SP)!=0); // true if key down
        interrupts();
        state=HANDSHAKE;
        if (key==0x5F)  fn=keydown;  // "Help" key: special function on/off
        else if (key==0x62) keystroke(0x39,0x00);  // CapsLock
        else {
          if (keydown){
            // keydown message received
            if (fn) {
              // special function with "Help" key 
              if (key==0x50) keystroke(0x44,0);  // F11
              else if (key==0x51) keystroke(0x45,0);  // F12
              else if (key==0x5A) keystroke(0x53,0);  // NumLock
              else if (key==0x5B) keystroke(0x47,0);  // ScrollLock
              else if (key==0x02) keystroke(0x14,0x40);  // @
              else if (key==0x04) keystroke(0x35,0x02);  // °
            }
            else {
              if ((key==0x2B) && (_keyReport.modifiers & 0x22)) keystroke(0x35,0x00);  // ^ (with shift)
              else if (key==0x00) if (_keyReport.modifiers & 0x22) keystroke(0x30,0x40); else keystroke(0x35,0x20); // ~,`
              else if (key==0x0D) if (_keyReport.modifiers & 0x22) keystroke(0x64,0x40); else keystroke(0x2D,0x40); // |,\
              else if (key==0x5A) if (_keyReport.modifiers & 0x22) keystroke(0x24,0x40); else keystroke(0x25,0x40); // {,[
              else if (key==0x5B) if (_keyReport.modifiers & 0x22) keystroke(0x27,0x40); else keystroke(0x26,0x40); // },]
              else if (key < 0x68) keypress(key);  // Code table
            }
          }
          else {
            // keyrelease message received
            if (key < 0x68) keyrelease(key);  // Code table
          }
        }
      }
    }
  }
  
  else if (state==WAIT_LO) {   // waiting for the next bit
    if ((PINB & BITMASK_A500CLK)==0) {
      noInterrupts();
      state=READ;
    }
  }
}
    

void keypress(uint8_t k) {
  
  if (k > 0x5f) _keyReport.modifiers |= ktab[key];  // modifier
  else {  
    for (uint8_t i=0; i<6; i++) {
      if (_keyReport.keys[i] == 0) {
         _keyReport.keys[i] = ktab[key];
         break;
      }
    }
  }
  HID_SendReport(2,&_keyReport,8);
}


void keyrelease(uint8_t k) {

  if (k > 0x5f) _keyReport.modifiers &= ~ktab[key];  // modifier
  else {  
    for (uint8_t i=0; i<6; i++) {
      if (_keyReport.keys[i] == ktab[key]) _keyReport.keys[i] = 0;
    }
  }
  HID_SendReport(2,&_keyReport,8);
}


void keystroke(uint8_t k, uint8_t m) {
  
  unsigned short memomodifiers = _keyReport.modifiers; // save last modifier state
    for (uint8_t i=0; i<6; i++) {
      if (_keyReport.keys[i] == 0) {
         _keyReport.keys[i] = k;
         _keyReport.modifiers = m;
         HID_SendReport(2,&_keyReport,8);
         _keyReport.keys[i] = 0;
         _keyReport.modifiers = memomodifiers; // recover modifier state
         HID_SendReport(2,&_keyReport,8);
         break;
      }
    }
}
A freeware to test (nearly) all keyboard functions: http://geekhack.org/index.php?PHPSESSID ... #msg641440

best regards
olaf
Dipl. Ing. (FH) Olaf Berthold Hardware- und Softwareentwicklung
www.olafberthold.de . . . . www.canhack.de . . . . www.cpos-online.de

User avatar
olaf
Posts: 11
Joined: Sat Nov 03, 2012 3:01 pm
Location: Germany, Friesland
Contact: Website

Re: Raspberry 500 / Amiga Pi ?

Thu Dec 27, 2012 9:07 pm

Here are some pictures.

The first conversion is a Nexoc Osiris E705 laptop with Intel Core 2 T9300 2,5GHz 8800GTX 4GB RAM, 380GB sata HD, Arduino Leonardo.
IMG_2801.JPG
"That is not a computer, THIS is a computer!" ;-)
IMG_2801.JPG (62.14 KiB) Viewed 4388 times
IMG_2797.JPG
2x USB, Firewire, Ethernet, Modem Socket at the original expansion port cutout
IMG_2797.JPG (58.04 KiB) Viewed 4388 times
IMG_2804.JPG
Commodore OS Vision
IMG_2804.JPG (63.15 KiB) Viewed 4388 times
Dipl. Ing. (FH) Olaf Berthold Hardware- und Softwareentwicklung
www.olafberthold.de . . . . www.canhack.de . . . . www.cpos-online.de

User avatar
olaf
Posts: 11
Joined: Sat Nov 03, 2012 3:01 pm
Location: Germany, Friesland
Contact: Website

Re: Raspberry 500 / Amiga Pi ?

Thu Dec 27, 2012 9:09 pm

The second will be a Raspberry Pi 512MB , Arduino Leonardo, IDE Harddrive with USB converter, active USB 4x hub.
A special feature is that everything will be mounted on the original AMIGA 500 mainboard and the original AMIGA power supply will be used.
IMG_2864.JPG
needs some time and afford...
IMG_2864.JPG (63.61 KiB) Viewed 4389 times
Dipl. Ing. (FH) Olaf Berthold Hardware- und Softwareentwicklung
www.olafberthold.de . . . . www.canhack.de . . . . www.cpos-online.de

Altairst8te74
Posts: 23
Joined: Mon Nov 19, 2012 10:08 pm

Re: Raspberry 500 / Amiga Pi ?

Fri Dec 28, 2012 1:00 pm

First up! Olaf you are a star m8 :)

second

I am blown away with the two amiga 500's... Mine well, I have hit a brick wall with trying to fit everything and keep messing something up. I need a new a500 base plastic/case so I can start again.

Happy Christmas to all :)

User avatar
olaf
Posts: 11
Joined: Sat Nov 03, 2012 3:01 pm
Location: Germany, Friesland
Contact: Website

Re: Raspberry 500 / Amiga Pi ?

Fri Dec 28, 2012 3:27 pm

Thank you very much, Altairst8te74,
but Thomas (thradtke) is the guy who deserves the credits.
Without his idea and his sourcecode we wouldn't be thus far.
I'm looking forward to see your pictures and pics of similar projects, too.

yours sincerely
olaf
Dipl. Ing. (FH) Olaf Berthold Hardware- und Softwareentwicklung
www.olafberthold.de . . . . www.canhack.de . . . . www.cpos-online.de

thradtke
Posts: 492
Joined: Wed May 16, 2012 5:16 am
Location: Germany / EL

Re: Raspberry 500 / Amiga Pi ?

Sat Dec 29, 2012 10:19 am

Thanks for your kind words, Olaf. I haven't done anything special, but it's very nice to see what came out of this :-). Should we ever meet, I'll spend Frieslands most famous beer - Jever Pilsener! :D

I noticed you're using COS. Is there anything special about it? In the beginning, I was hoping for API level Amiga support (like in Apples Carbon), but smelling the demise of CUSA in terms of prices, forum comments and dwindling product range, I guess this will never happen.
Rocket Scientist.

Altairst8te74
Posts: 23
Joined: Mon Nov 19, 2012 10:08 pm

Re: Raspberry 500 / Amiga Pi ?

Sun Dec 30, 2012 11:34 pm

Yup credit where its due! Thank you Thomas :D

User avatar
olaf
Posts: 11
Joined: Sat Nov 03, 2012 3:01 pm
Location: Germany, Friesland
Contact: Website

Re: Raspberry 500 / Amiga Pi ?

Tue Jan 01, 2013 11:15 pm

COS is actually linux mint. I played around a little with COS, because it looks really cool and feels a bit like the old commodore days. It comes with a bunch of software, audio/video tools, games and of course emulators for all commodore machines.

But my plan for the intel amiga is to install win xp, winuae, ccs64, mame, scumm, snes and some other emulators, old dos games, and remakes of classic games. So it will be the perfect retro gaming pc in an adequate case.
The raspberry amiga will be used as a multimedia player.
Dipl. Ing. (FH) Olaf Berthold Hardware- und Softwareentwicklung
www.olafberthold.de . . . . www.canhack.de . . . . www.cpos-online.de

pawelkrak
Posts: 35
Joined: Wed Jan 16, 2013 3:46 pm

Re: Raspberry 500 / Amiga Pi ?

Wed Jan 16, 2013 3:50 pm

Hello all ;)

I have some problems with sketch. After inserting latest sketch by OLAF i got some errors :(

sketch_jan16c:13: error: 'KeyReport' does not name a type
sketch_jan16c.ino: In function 'void setup()':
sketch_jan16c:38: error: 'DDRF' was not declared in this scope
sketch_jan16c:39: error: 'PORTF' was not declared in this scope
sketch_jan16c.ino: In function 'void loop()':
sketch_jan16c:50: error: 'HID_SendReport' was not declared in this scope
sketch_jan16c:55: error: 'PINF' was not declared in this scope
sketch_jan16c:57: error: 'HID_SendReport' was not declared in this scope
sketch_jan16c:121: error: '_keyReport' was not declared in this scope
sketch_jan16c.ino: In function 'void keypress(uint8_t)':
sketch_jan16c:149: error: '_keyReport' was not declared in this scope
sketch_jan16c:152: error: '_keyReport' was not declared in this scope
sketch_jan16c:158: error: '_keyReport' was not declared in this scope
sketch_jan16c:158: error: 'HID_SendReport' was not declared in this scope
sketch_jan16c.ino: In function 'void keyrelease(uint8_t)':
sketch_jan16c:164: error: '_keyReport' was not declared in this scope
sketch_jan16c:167: error: '_keyReport' was not declared in this scope
sketch_jan16c:170: error: '_keyReport' was not declared in this scope
sketch_jan16c:170: error: 'HID_SendReport' was not declared in this scope
sketch_jan16c.ino: In function 'void keystroke(uint8_t, uint8_t)':
sketch_jan16c:176: error: '_keyReport' was not declared in this scope
sketch_jan16c:181: error: 'HID_SendReport' was not declared in this scope

what wrong i was doing ? mayby someone has a good working sketch for leonardo ? I got ARDUINO 1.3 for windows.

Thanx ;)

regards Paul

User avatar
Wizard
Posts: 120
Joined: Sun Aug 19, 2012 4:52 am
Location: Sweden

Re: Raspberry 500 / Amiga Pi ?

Wed Jan 16, 2013 8:25 pm

pawelkrak wrote:Hello all ;)

I have some problems with sketch. After inserting latest sketch by OLAF i got some errors :(
snip

what wrong i was doing ? mayby someone has a good working sketch for leonardo ? I got ARDUINO 1.3 for windows.
Do you mean 1.0.3?

It looks like you've got some issue with the installation of the Arduino IDE...
...or you've configured the IDE for the wrong board.

Make sure that the sketch is compiling against the correct board and try again.
Raspberry Pi - finally a worthy replacement for A500!!!

pawelkrak
Posts: 35
Joined: Wed Jan 16, 2013 3:46 pm

Re: Raspberry 500 / Amiga Pi ?

Wed Jan 16, 2013 8:28 pm

dadam, i got change config in main menu for ARDUINO LEONARDO then check pass OK :)

waiting for A500 case and i make A500 mini PC with real a500 kbd :mrgreen:

pawelkrak
Posts: 35
Joined: Wed Jan 16, 2013 3:46 pm

Re: Raspberry 500 / Amiga Pi ?

Fri Jan 18, 2013 8:03 pm

hi guys

i have antoher problem. Im wiring my A500 kbd to LEONARDO with this colors sets:

Amiga color:

blue=gnd
orange= 5v+
red= leonardo pin 10
black=leonardo pin 9
brown=leonardo pin 8

PURPLE & GREEN reserved for led power in main ITX pcb.

Just loaded the OLAF sketch into my leonardo but kbd doesn;t work :( nothing happen ?

I bought new leonardo. Mayby i need to brun bootloader? where can i get files for leonardo for buring bootloader ? whats wrong i was doing ?

thanx
regards Paul

pawelkrak
Posts: 35
Joined: Wed Jan 16, 2013 3:46 pm

Re: Raspberry 500 / Amiga Pi ?

Fri Jan 18, 2013 9:21 pm

changed blue for green wire. But when connect my leonardo board to the USB port, i have
UNKOWN DEVICE. Kbd not working :(. Whats wrong ? i dont have idea how to do working my a500 kbd under windows7 :(. Waiting for help :)

regards Paul

thradtke
Posts: 492
Joined: Wed May 16, 2012 5:16 am
Location: Germany / EL

Re: Raspberry 500 / Amiga Pi ?

Sat Jan 19, 2013 9:37 am

How do you power the keyboard controller? Does the caps lock LED light up on power up?
Rocket Scientist.

User avatar
Wizard
Posts: 120
Joined: Sun Aug 19, 2012 4:52 am
Location: Sweden

Re: Raspberry 500 / Amiga Pi ?

Sat Jan 19, 2013 10:14 am

Skip the A500 keyboard for a while and make sure the rest works first.

Use an example like this and verify the computer<->Leonardo works

Code: Select all

void setup() {
  // make pin 2 an input and turn on the 
  // pullup resistor so it goes high unless
  // connected to ground:
  pinMode(2, INPUT_PULLUP);
  Keyboard.begin();
}

void loop() {
  //if the button is pressed
  if(digitalRead(2)==LOW){
    //Send the message
    Keyboard.print("Hello!");
  }
}
When this works as expected, wire in the keyboard and try again.
When I first played around with an A500 keyboard I just read the key-codes and printed them with Serial.print() to the serial monitor in the Arduino IDE. This is a pre-req when troubleshooting.

Good luck!
Raspberry Pi - finally a worthy replacement for A500!!!

Return to “Other projects”