Friday, May 19, 2006

 

Simkits rulez

I have just received an email from Simkits: "...your order have been shipped". Tears almost choke me as I write this: I only had to wait 49 days after ordering this and voilá: it has shipped! I don't even care if they included the free USB hub as promised or not (it is not stated in the confirmation email).

I also bought a few PIC16F88 the other day; maybe I will take some chances with I2C after all...

Although stepper motors would be a far more logical choice for instruments with an arbitrary number of turns (like heading indicator or altimeter), they are hard to get and even harder to replace. You can tear apart old printers or floppy drives, but you will have to determine the step/revolution for that specific motor, adjust firmware and/or gear set accordingly. And what happens if the motors breaks down? You will probably have a hard time to find a replacement and I'm pretty sure you won't be lucky to find a motor with the same voltage and same steps/revolution.... So modified servo seems to be the way to go (with the extra pain of position feedback).

Monday, May 15, 2006

 

Some progress

On the 45th day since placing an order on Simkits.

I hope to get this company to cut the upper panel using simkit's publicly available cessna.dwg. I bought some construction material like acrylic (plexi) in Praktiker and 1mm and 0.5mm thick aluminium sheets at a local hardware store. Also ordered some small parts (gears, shafts etc) from here.
I looked at the programming aspects of driving an LCD module (I have a Displaytech 162B module, 2x16 char with backlight) with the digital clock in mind. It is quite straightforward, especially since Nigel has a very good tutorial.

Thursday, May 11, 2006

 

The big picture

The solution for driving the upper panel (from small gauges to large gauges) is slowly getting shape. I will need 5 or 6 PICs to drive the servos and (in case of modified servos) read position feedback, optical interrupter, rotary encoder, things like that.
I will build:

"power board"
6 DB9 connectors to connect to PC's 6 serial ports
power connector to standalone ATX power supply (hacked to power up without PC)
dimmer circuit outputting 5V-10V regulated by potentiometer
6 DB9 connectors to connect to "control boards", this connection will provide TX,RX,GND,+5V,+12V,dimmer output to control boards

"control board"
1 DB9 to connect to power board and receive TX,RX,GND,+5V,+12V,dimmer output
78L05 to create +5V from +12V for logic circuit
MAX232N to interface to RX,TX
PIC16F628A or PIC16F88 as needed
connectors as needed (illumination LEDs from dimmer voltage, servo connector etc.)
servos will be driven from +5V from ATX power supply (to separate from logic circuit)

PC - power board and power board - controller boards are connected with null-modem or serial extender cable (I have to make sure not to mess up which line goes where).

It means installing 4 additional serial ports to the PC. Not really nice, but this way I can develop and test different control boards individually and later simply plug them all into PC. Also it (hopefully) eliminates the need for some kind of addressing scheme (PC control software will "know" which control board is connected to which COM port).

"Miles to go before I sleep" :-)

Monday, May 08, 2006

 

Servo control from flightsim cont.

I have entirely rewritten the firmware using idea from Mike's book. The main idea is to set up timer2 of the PIC to fire every 20ms. The interrupt routine will start timer1 according to a 2 byte delay. With both timer interrupts enabled, the firmware is something like

set up timer 2 to fire every 20ms and enable interrupt for it
main loop
check if serial input is available (RCIF flag in PIR1)
if serial is available then read 2 bytes and put it into pulse width delay parameter
goto main loop

interrupt routine
if firing because of timer2 then enable servo control output, set timer1 to delay parameter, enable interrupt for it
if firing because of timer1 then disable servo control output

It worked much better then previous version, since timer1 enables me to control pulse width with precision of one instruction cycle. Since PIC is using internal 4Mhz oscillator, it means pulse width precision of 1usec (or 0.001 ms). Of course I had to slightly change the interface C program to send correct values for TMR1L and TMR1H. The servo movement was much smoother then previously. If I clock the PIC using an external oscillator, then this would allow me even more precise pulse width control (using let's say 20Mhz, one instruction cycle goes down to 0.2 usec or 0.0002 ms).

The firmware for driving 8 simple servos (for example all small gauges with one PIC) is getting shape, again using idea from Mike's book, something like:

set up timer 2 to fire every 2.5ms and enable interrupt for it
main loop
check if serial input is available (RCIF flag in PIR1)
if serial is available then read x bytes and put it into pulse width delay parameter of appropiate servo
goto main loop

interrupt routine
if firing because of timer2 then enable next servo control output, set timer1 to delay parameter, enable interrupt for it
if firing because of timer1 then disable actual servo control output

This way each servo is served in 2.5ms*8 = 20ms intervals.

By the way: I'm still waiting for the Simkit delivery (it has not even shipped yet). Just for the record:
If simkits tells me the truth, it means the original stock was sold out in about 17 hours and they were not able to get new parts in about 25 business days. Remember, I fabricated this kind of input myself, no fancy and/or rare items were used and the firmware was almost trivial. If I add that I ordered the kit (no assembly needed on Simkits part), I start to wonder about their business model. I really hope that was the last thing I had to order from them.

 

Servo control from flightsim

I created a small C program which connects to Microsoft FS 2002 via FSUIPC 2.96 (free), reads indicated airspeed, calculates delay constant and sends it to servo control circuit using RS232 if it needs to be changed. It worked remarkably well. The FSUIPC SDK is really well documented, it was quite easy to create this small interface program. You can imagine my joy when the servo horn moved as the airspeed indicator moved on the screen! Well, the physical movement is constrained to 120 degrees since no gearset or anything like that was used in the simple setup. Still, it is clearly visible that I have to work on more precise timing since the servo horn moved in relatevily big jumps. This would be much more emphasized if it would be geared to 1:3 to allow an almost full turn of the airspeed indicator needle.

Friday, May 05, 2006

 

Servo control cont.

Quickly implemented an RS232 interface to the servo testing circuit. It is a textbook solution using MAX232N for interfacing and hardware USART built into PIC. I connected the thing to the PC with a null-modem cable and used this software to send pulse width delay constant to the PIC. The setup worked on the first attempt, it was really easy to implement RS232 input. No interrupts used so far, firmware is something like:
main loop
delay for 20 ms
raise one output pin to logic 1
delay for some time some according to parameter
lower output pin to logic 0
check if serial input is available (RCIF flag in PIR1)
if serial is available then read byte and put it into pulse width delay parameter
goto main loop

This setup enabled me to try the servo's reaction to pulse widths well outside specification. The servo was able to turn much more then the specified 120 degrees (almost 180) but the needed control pulse width change was not linear when driven outside the specifications.

Thursday, May 04, 2006

 

Servo control

I have made a simple circuit using PIC16F628A to try and drive one RC servo (Futaba S3003). I implemented it without the PWM module. It is simply

main loop
delay 20ms
raise one output pin to logic 1
delay for some time some (between 1ms and 2ms)
lower output pin to logic 0
goto main loop

It worked (after actually checking which is the servo signal wire). I played with it for some time, but since the circuit doesn't implement any input from the outside world, the "play" consisted of
getting PIC out
changing pulse width delay counter in formware
burn new firmware
put PIC back
power up circuit

Next step will be some kind of input to ease further testing.

This page is powered by Blogger. Isn't yours?