k-Pack Posted November 17, 2016 Share Posted November 17, 2016 I want to control 6 hobby servos but first I want to be able to control 1. I've been trying to use Bob Woolley's programs as laid out in In Atari Classics January/February 1996 article. I've typed in the assembly program into MAC/65 and triple checked it for typing errors. I don't have a servo hooked up but it seems to hang up while setting up the DLI or shortly after. I'm going to have to study the code a little more to understand the NOP in line 470, but what I really don't understand starts at line 530 JSR $0681, Line 580 sets the assembler's location counter to $0680, then line 620 LDA #$00. Won't this start the JSR with a BRK($00)? Here's the ASM code from VOL3_2.atr that I recently found. See anything else that might help? 0100 ;SERVO.ASM 1/27/96 0110 ;BY BOB WOOLLEY ATARI CLASSICS 0120 ; 0130 ; 0140 *=$600 0150 ; 0160 ;BASIC CALL..SET UP VBI 0170 ; 0180 PLA ;REQUIRED BY BASIC USR() 0190 LDY #$40 ;VECTORS VBI TO $640 0200 LDX #$06 0210 LDA #$07 0220 JSR $E45C 0230 ; 0240 LDA #$30 ;SETS J/S PORTS TO 0250 STA $D302 ;OUTPUT 0260 LDA #$FF 0270 STA $D300 0280 LDA #$3C 0290 STA $D302 0300 RTS 0310 ; 0320 ; 0330 *=$640 0340 ; 0350 ;VBI..WRITE TO SERVO 0360 ; 0370 LDA #$FF ;ALL PINS TO 1 0380 STA $D300 0390 ; 0400 LDY #$C0 ;DELAY FOR .5MS 0410 LPY DEY 0420 BNE LPY 0430 ; 0440 LDX #$00 ;CONSECUTIVE LOAD 0450 LP1 LDA $8000,X ;FROM $8000 0460 STA $D300 ;TO J/S PORT 0470 NOP ;INCREASES RANGE 0480 INX ;NEXT BYTE 0490 BNE LP1 0500 ; 0510 LDA $06FF ;FLAG $8000 UPDATE 0520 BNE RETN 0530 JSR $0681 ;DO UPDATE 0540 INC $06FF ;RESET FLAG 0550 RETN JMP $E462;END VBI 0560 ; 0570 ; 0580 *=$680 0590 ; 0600 ;UPDATE BIT MAP 0610 ; 0620 LDA #$00;ZERO $8000-$80FF 0630 TAX 0640 LP2 STA $8000,X 0650 DEX 0660 BNE LP2 0670 ; 0680 LDY #$07 ;STORE CONTROL BYTES 0690 LDA #$01 ;STARTING WITH BIT 0 0700 STA $06FE; BIT INDEX 0710 LP3 LDX $6C0,Y ;STOP ADDRESS 0720 JSR STORE 0730 ASL $06FE ;NEXT BIT 0740 DEY; NEW CONTROL BYTE 0750 BPL LP3 0760 RTS 0770 ; 0780 STORE 0790 LP4 LDA $7FFF,X;GET CURRENT BYTE 0800 ORA $06FE ;UPDATE THE BIT 0810 STA $7FFF,X ;STORE NEW BYTE 0820 DEX ;NEXT BYTE 0830 BNE LP4 ;UNTIL AT $8000 0840 RTS ;DONE 0850 ; 0860 ; 0870 *=$6C0 0880 ;SERVO CONTROL BYTES (ARBITRARY) 0890 .BYTE $80,$40,$20,$10 0900 .BYTE $08,$04,$02,$01 0910 ; 0920 .END Quote Link to comment Share on other sites More sharing options...
Rybags Posted November 17, 2016 Share Posted November 17, 2016 I assume this example is using multiple bits which then go to a resistor ladder or DAC to create a variable voltage? If this isn't what you want then you're better to start off from scratch. Also, it's not really good practice to have stuff like JMP $681 when the destination can potentially change, better to use labels. Right you are about that JMP to a BRK. The only reason for that would be if using the Atari Asm/Ed cartridge as a breakpoint or to provide a short delay in normal operation. But using BRK to create a delay isn't good practice, normally BRK will be passed over by the IRQ handler but it's not guaranteed. I suspect it's just a programming mistake. How you go about this stuff depends on how the control of the servos takes place. If it was just pure digital on demand and not going through phases or voltage ramps then you could probably just do it by directly masking and changing the PORTA bits. Quote Link to comment Share on other sites More sharing options...
k-Pack Posted November 18, 2016 Author Share Posted November 18, 2016 I assume this example is using multiple bits which then go to a resistor ladder or DAC to create a variable voltage? The program needs to output a variable width pulse. Timing is everything. I thought it would easily control up to 8 servos, and it would if it would work. The more I look at the code the less sure I am it will work. I'm switching to plain B - There is a series of 4 articles in ANTIC 12/83, 1/84, 6/84, and 7/84 by Evan Rosen. I'm hoping I can find the code I need within these articles. I'll probably post the results in the "Out of the Pack" blog. Maybe before spring. Quote Link to comment Share on other sites More sharing options...
Rybags Posted November 19, 2016 Share Posted November 19, 2016 Variable pulsewidth is easy enough but what would the carrier frequency need to be? The thing is though, you shouldn't attempt to drive big loads from the inputs - not sure what the limits are but I'd guess in the pretty low mA range. Quote Link to comment Share on other sites More sharing options...
k-Pack Posted November 19, 2016 Author Share Posted November 19, 2016 Variable pulsewidth is easy enough but what would the carrier frequency need to be? The thing is though, you shouldn't attempt to drive big loads from the inputs - not sure what the limits are but I'd guess in the pretty low mA range. The servo can be controlled with a 60hz pulse with a pulse length between 1 and 2 milliseconds. There is a circuit built into the servo that translates pulse into an angular position. I will be using an external power source for the servos. I will also be looking into using an optocoupler for a bit more protection. This is a link to the 4 articles that appeared in Antic magazine. So far it looks like plan B will work. http://www.atarimagazines.com/index/index.php?author=Evan+Rosen&mag=antic Quote Link to comment Share on other sites More sharing options...
+bob1200xl Posted November 19, 2016 Share Posted November 19, 2016 I used the ASM/ED cartridge for this program - don't know if it matters. I would say that $681 is incorrect - try $680? Do you have the code that was on the disk? That should work. Most of my Atari things are still packed away, but I can try to find the SERVO files. Bob Quote Link to comment Share on other sites More sharing options...
k-Pack Posted November 20, 2016 Author Share Posted November 20, 2016 I used the ASM/ED cartridge for this program - don't know if it matters. I would say that $681 is incorrect - try $680? Do you have the code that was on the disk? That should work. Most of my Atari things are still packed away, but I can try to find the SERVO files. Bob Bob, I tried the $681 to $680 with no success. I'm going to try the ANTIC article and software so not sure if you need to open up the old boxes for me. Although if your looking for an excuse to open them, I'd like to see what the working code looks like. I have 15 issues of Atari Classics and was thinking that was all the issues. Vol 5 -No 1 has the servo article. There doesn't seem to be any corrections in issue Vol 5 - NO 2(which is the last I own). It does mention the programs being on "Atari Classics Disk - Volume 5 & 6". I got my version from VOL3_2.atr. Now that I look at it, this disk may be from someone's collection or maybe not. The code on this disk matches the print listing. Quote Link to comment Share on other sites More sharing options...
+bob1200xl Posted November 21, 2016 Share Posted November 21, 2016 I'll see what I can find next time I visit my storage lockers... Bob Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.