Using Flowcode to pgm an atari style joystick

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

icabjeff
Posts: 34
Joined: Thu Jul 27, 2006 11:00 pm
Location: Newton, NJ, USA
Contact:

Using Flowcode to pgm an atari style joystick

Post by icabjeff »

I want to use Flowcode to pgm a atari 2600 joystick adapter box. Does anybody know what e-blocks would allow me to input the signal from an atrari joystick and output it to three atari 2600 nine pin cables . i want to pgm a multi-click feature which allows the use of one switch to operate three separate swiches according to how mant times you press the switch. Is Flow code powerful enough? Thanks a lot! Jeff

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

You should be able to use Flowcode for this.

If you use E-Blocks, you will probably need to create some of your own hardware, so I'd suggest a multiprogrammer (EB-006) and a patch or prototype board (EB-016 or EB-017).

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

I have integrated a PIC with a PC style D type 15pin Joystick. If this is similar to what you require then let me know and I will send you my files.

icabjeff
Posts: 34
Joined: Thu Jul 27, 2006 11:00 pm
Location: Newton, NJ, USA
Contact:

Post by icabjeff »

I've adapted an X-Arcade game console arcade control with three dsub9 pin plugs to accept handicapped switches (which use the same technology as Atari 2600 joysticks). I'm vague on how exactly communication takes place with the PIC micro. On input, when I complete a given circuit by pushing the stick how does the Pic chip know this and on output how does it complete the circuit for the chosen X-Arcade switch.

jeff

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

The X and Y axis will probably be represented by a analogue signal. Eg when the joystick is centered both x and y signals will be around 2.5V. It is therefore simply a case of measuring the analogue voltage and working out the position.

As for the buttons these should be standard digital inputs. Depending on how many buttons there are on the joystick there could be some multiplexing that acts as an array to control the switches. In this case it would also need some digital output signals to search through the switch array to find the pressed switch.

icabjeff
Posts: 34
Joined: Thu Jul 27, 2006 11:00 pm
Location: Newton, NJ, USA
Contact:

Re:

Post by icabjeff »

Benj wrote:The X and Y axis will probably be represented by a analogue signal. Eg when the joystick is centered both x and y signals will be around 2.5V. It is therefore simply a case of measuring the analogue voltage and working out the position.

As for the buttons these should be standard digital inputs. Depending on how many buttons there are on the joystick there could be some multiplexing that acts as an array to control the switches. In this case it would also need some digital output signals to search through the switch array to find the pressed switch.
I have finished a preliminary flowcode flowchart and successfully burned it to chip. I used a EB002-00-1 screw terminal block to create an adapter from a digital atari style joystick to the multiprogrammer. I redirected pin #8 which is used for ground on the stick to ground pin #9 of the screw terminal block. I get no input. What might I be doing wrong? Am I missing an important concept here?

Thanks,
Jeff

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by Benj »

Hello Jeff

What are your other connections. You mentioned the Ground line but what are the Joystick X and Y pins connected to etc. Pins and Ports of the chip may be helpful.

icabjeff
Posts: 34
Joined: Thu Jul 27, 2006 11:00 pm
Location: Newton, NJ, USA
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by icabjeff »

Here is a diagram of my atari style joystick to multiprogrammer adapter. I added two mono plugs and a togle switch to get eight inputs
screwterminal.jpg
screwterminal.jpg (75.75 KiB) Viewed 16606 times
When i tested this with a multimeter checked out. Since the atari joystick uses a minute amount of flow could the safety resistors be preventing the other swithes from working?

Jeff

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by Benj »

Hi Jeff

This page might be useful to you. Note the pull up resistor used for the analogue signal and the pull down resistors used for the digital I/O.

http://www.helmpcb.com/Electronics/USBJ ... stick.aspx

If you create your circuitry like this then the 220R series resistors shouldn't cause you any problems.

icabjeff
Posts: 34
Joined: Thu Jul 27, 2006 11:00 pm
Location: Newton, NJ, USA
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by icabjeff »

I added the resistors to input and it checks out good. I checked for input using the LCD display e -block. I'm having trouble getting my flowcode program to display on my LCD display e-block. I ran the test HEX file successfully on a 16F88 PIC. So I know the LCD works. But when downloaded the RealTimerClock TMR0 example program and burn to a 16F877A PIC chip nothing displays on the LCD.

Configure
Oscillator: RC
Watchdog timer: Off
LCD on PORTB

Jeff

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by Benj »

Hello Jeff

To drive the LCD you will either have to place the oscillator into XTAL mode rather then RC or you will have to lower the clock frequency setting in Flowcode to a rate to match your RC clock speed. If you dont know your RC clock speed then do the 1 second LED flash test. This is where you create an infinite loop that outputs a 1 to a pin waits a second outputs a 0 to the pin and waits a second again. Doing this you can change your clock speed setting in Flowcode to get the correct delays of 1 second.

icabjeff
Posts: 34
Joined: Thu Jul 27, 2006 11:00 pm
Location: Newton, NJ, USA
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by icabjeff »

I wired up one pull-up resistor on a proto board connected to a multiprogramer through a screw terminal. I'm using an atari joystick connected to one the proto boards db9 plugs as an input switch.

switch was held closed for 1 sec.
outcome: LCD flashing cursor then SUCCESS!!!x2 approx. 10 sec after the switch was open again.

Any idea of what is causing the delay?

Thanks
pull-uptest.jpg
pull-uptest.jpg (158.55 KiB) Viewed 16488 times
Attachments
flowcode.jpg
flowcode.jpg (130.95 KiB) Viewed 16483 times

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by Steve »

It could be that the 16F88 chip is defaulting to the 31.25kHz internal oscillator. It will do this if the clock source of the chip is not working.

You should create a simple LED flasher circuit as suggested bu Ben to ensure that the clock frequency you have set in Flowcode is the actual frequency that the chip is running in.

icabjeff
Posts: 34
Joined: Thu Jul 27, 2006 11:00 pm
Location: Newton, NJ, USA
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by icabjeff »

I forgot to mention that I'm using a PIC 16F877A1P. If that makes a difference.

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by Steve »

It does as this chips doesn't have an internal oscillator or a fail-safe clock mode.

But it does look like your program is running much slower than expected. Have you written a simple led-flasher app to check that the clock speed setting is correct for your hardware?

icabjeff
Posts: 34
Joined: Thu Jul 27, 2006 11:00 pm
Location: Newton, NJ, USA
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by icabjeff »

I reburned to chip and now my program doesn't run slow.

I tested a 3.5 volt LED with a 9 volt battery and a 10 k resistor successfully. So, I know that the LED lights up. I then used the LED to test output of a single bit. As you can see on LEDschem.jpg this didn't work because it was wired wrong. I found
a web page about LED interfacing that has a circuit you can see in led interfacing.jpg.I haven't tested the circuit yet. Is it the correct set up for me? Also, once I've tested all of my outputs with LEDs how do I bring my outputs back to the no real power of their own state they started at before input. I'm trying to connect my outputs to a screw terminal to Playstation 2 adaptor.
LEDschem.jpg
LEDschem.jpg (75.96 KiB) Viewed 16401 times
led_interfacing.JPG
led_interfacing.JPG (34.22 KiB) Viewed 16396 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by Benj »

Hello

The picture "led_interfacing.JPG" shows an example for driving an LED. This circuit will light the LED when the I/O pin is outputting 0 and will go out when the I/O pin is outputting a 1.

You can also wire up LEDs so that they are driven via the I/O pin. E g keep R1 and D1 together but connect the free end of R1 to the I/O pin and connect the free end of D1 to Ground or 0V. This will then give you the functionality of switching on the LED when the I/O pin is outputting a 1.

You could also change the resistor for a 330Ohm resistor if you want the LED to be brighter.

My advice is get a breadboard. They allow you to insert and remove components without soldering and you can therefore experiment with different configurations.

This product may be of interest to you.
http://www.matrixmultimedia.com/product ... PHPSESSID=

icabjeff
Posts: 34
Joined: Thu Jul 27, 2006 11:00 pm
Location: Newton, NJ, USA
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by icabjeff »

I'm only using LED's to test if my outputs work. I plan to output from two dsub9 ports to four dsub9 plugs set up with atari joystick wired pin arrangements with a proto board . So, how do I output a signal that will be seen as atari digital joystick signals. Signals that don't have any real possible power their own.

icabjeff
Posts: 34
Joined: Thu Jul 27, 2006 11:00 pm
Location: Newton, NJ, USA
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by icabjeff »

I'm using my X-arcade modified with dsub 9pin connectors to test output signals from the PIC.

When I tested the output with a multimeter I got a reading of 25ma for one second every time I pushed the joystick forward. Just as the program tells it to do.

When I onnected the X-arcade to the breadboard I had constant output, no distinct signal from joystick.

How do make the output work like a physical joystick switch so the X=arcade can read it.

icabjeff
Posts: 34
Joined: Thu Jul 27, 2006 11:00 pm
Location: Newton, NJ, USA
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by icabjeff »

Became the X-Arcade uses one ground for every four switches as opposed to a comman ground throughout all switches I found it necessary to use a different way to interface with the Playstation. Ultramart makes a keyboard encoder that can be used to connect to that Playstion with an adaptor. Here is the question I asked Ultramarc about connecting to their keyboard encoder to a PIC.
“I'm making a handicapped accessible programable arcade control adaptor with a PIC chip.
When I tested the output with a multimeter I got a reading of 25ma every time I pushed the joystick forward. But I need a signal that is the same as what an arcade control puts out. How do I turn this output into an input that mimics a physical joystick so I can connect it to an I-PAC


Jeff



On May 19, 2009, at 3:22 AM, andy@ultimarc.com wrote:
Jeff,

The input to the I-PAC has a 7 K resistor to 5 volts, which pulls it high. Closing a connected switch pulls it low to ground, as the other side of the switch is grounded. So the PIC needs to replicate this by pulling to ground when activated.

Andy”

Does anybody have any thoughts or suggestions on how to do this?

Thanks,
Jeff

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by kersing »

The safest option would be to use opto-couplers or relays (i.e. E-blocks relay board). This makes sure the PIC signals are decoupled from the adapters signals. (The opto-couplers should be connected as outputs, not inputs like the Eblocks Opto-isolator board)
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

icabjeff
Posts: 34
Joined: Thu Jul 27, 2006 11:00 pm
Location: Newton, NJ, USA
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by icabjeff »

Good idea, but I need a solution that will allow output from each of the eight individual bits. Do you know of anyway this can be done? Can you suggest any alternatives?

Jeff

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by kersing »

Eight opto-couplers/relays... (opto couplers will probably be cheaper, relays when using two e-blocks will be easier) Just use a opto-coupler/relay for each output bit.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

icabjeff
Posts: 34
Joined: Thu Jul 27, 2006 11:00 pm
Location: Newton, NJ, USA
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by icabjeff »

If I want to be able to use all the buttons on the Playstation 2 I will need to use two ports aand fourteen opto couplers. I think this will use too much space on the final PCB and he too expensive. Are there any alternatives? Is there a resistor that can draw power down to zero and pull-down to ground.

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Using Flowcode to pgm an atari style joystick

Post by kersing »

If you decide not to use opto-couplers or relays you'll need to connect the signals of both circuits. This might work fine, however you'll have to be careful witch way the PIC circuit is powered as doing things wrong might damage the Playstation. (This would be a perfectly valid solution when done the right way)

The size and price issues are relative. There are chips with 4 opto-couplers in one 16 pin DIL for about $ 1,70 (ISP321-4X) and that's not even the cheapest. Four of those combined with a hand full of resistors should solve your problem. If you need a smaller component, look for SMD (ACPL-247-500E) with several choises priced around $2. Using about $8 of components to make sure the playstation is not put at any risk sounds not too expensive to me...
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Post Reply