Jump to content

Banner.jpg.b83b14cd4142fe10848741bb2a14c66b.jpg

Marci

Members
  • Posts

    484
  • Joined

  • Last visited

Everything posted by Marci

  1. @tekkydave - I need to modify the AAF2 ASCOM driver to poll for position - ie: send the P# command every 10s or similar - rather than just assuming the focuser has done as it’s told and that it’s ONLY being controlled via ASCOM (it isn’t - it can also be controlled by a local web interface)... any pointers?
  2. Ta! Not a lot else to do at the mo... *glares at clouds*
  3. Pt4 - Introducing... Node-Red Blog Version | Pt1 | Pt2 | Pt3 **WARNING: Copious amounts of dull code. Wind to the bottom of the post for the video of what it all does** Today’s the day we get a grip… we take a stand… we GET CONTROL. We’re going to install Node-Red and a few plugins, then we can finally shift away from playing typey-typey on a keyboard and get some more standardised control of our motors. Once we reach the end of this step, you’ll be able to control your motors using a USB Game Controller, any mobile device, over the web, via SkySafari using the Nexstar protocol… we’ll have basically achieved pretty much the level of control of a Dual Axis motor driven scope, non-GoTo. (If you remember from Pt3, I can’t work on getting the GoTo part of things running until my motor feedback encoders have turned up). Node-Red: The LEGO™ of Code. As per Pt3, our Pi is now running headlessly, so plugin the 12v PSU from your DRV8835 board, give it a minute to boot, then connect using SSH. Before we can install Node-Red, we need to install Node. To do this we need the download link, and the download link depends on which RaspberryPi you’re using. Open the Node download page. On there you’ll see 3x download links for Linux Binaries entitled ARMv6, ARMv7, and ARMv8. You need to right click and select “copy link” / “copy shortcut” / “copy target” (all depends what browser you use) on the correct one for your particular Pi. Raspberry Pi 1 Model A / A+ / B / B+, or Zero = ARMv6 Raspberry Pi 2 Model B = ARMv7 Raspberry Pi 3 Model B = ARMv8 In your SSH window type… wget … followed by a space, then right click > paste the copied link. Here’s what it looks like for me at the time of writing on my model B+ wget https://nodejs.org/dist/v6.9.2/node-v6.9.2-linux-armv6l.tar.xz Bash enter, and it’ll download that file and we can extract it. To do that we need the filename part of the link! That’s everything after the final /. Then we need the same but without the .tar.xz on the end. Look over both bits of code and you’ll see what I mean. tar -xvf node-v6.9.2-linux-armv6l.tar.xz cd node-v6.9.2-linux-armv6l sudo cp -R * /usr/local/ That’s Node installed, and this will also have installed the node package manager tool for us… npm. The reason installing node like this is a pain is because it’s version number, the v.6.9.2 in the commands above, changes over time as they release new updates. However, doing it this way is much more reliable. The npm tool makes installing Node packages such as Node-Red MUCH simpler. You can copy and paste the code exactly from here on as there are no version numbers that are likely to change. Just copy and paste each line, hitting enter after each. sudo npm cache clean sudo npm install -g --unsafe-perm node-red Now, if you’re doing this on a Mobile B+ or earlier go and amuse yourself for an hour or two. Installing Node-Red takes a LONG time on the more basic Raspberrys. On my Model B+, I managed a cigarette, breakfast, coffee and a shower in the time it took to complete. If you’re doing it on a Pi3, it’ll probably rattle through whilst you make a quick brew. Once that’s done, run the next lump of commands. These download some scripts which make node-red start automagically when you fire up your Pi. sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/nodered.service -O /lib/systemd/system/nodered.service sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-start -O /usr/bin/node-red-start sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-stop -O /usr/bin/node-red-stop sudo chmod +x /usr/bin/node-red-st* sudo systemctl daemon-reload Next we need to edit the /lib/systemd/system/nodered.service and tell it that user=root. pico /lib/systemd/system/nodered.service Use the arrow keys to move down to this line: User=pi and change it to User=root To save the changes and quit the editor, press Ctrl + O followed by Ctrl + X. Now run the following commands which enable Node-Red, and install a few necessary plugins to allow us to control things attached to the Pi’s GPIO pins (ie: our DRV8835): sudo systemctl enable nodered.service cd ~/ git clone git://git.drogon.net/wiringPi cd wiringPi ./build cd ~/ sudo npm install -g raspi-io --unsafe-perm --force sudo npm install -g node-red-contrib-gpio --unsafe-perm --force sudo npm install -g node-red-contrib-admin --unsafe-perm sudo npm install -g node-red-dashboard --unsafe-perm sudo passwd root {set a password when prompted!} su {enter the password when prompted!} mkdir ~/.node-red && cd ~/.node-red npm install wiring-pi --unsafe-perm npm install node-red-node-base64 We need to make a tweak to a file that was installed during the above next… pico ~/.node-red/settings.js Use the arrow keys to move down to the line containing the following: functionGlobalContext: { and add a line directly beneath it as follows: wpi: require('wiring-pi’) Ctrl + O to save, Ctrl + X to exit. And now, finally, run the following… exit sudo reboot You can breathe now. That’s pretty much the last time we’ll need to anything major on the commandline with a bit of luck. Give it a few minutes to reboot and for everything to start, and then fire up a web browser, and navigate to our device using the name we set in Pt3, the same name we used for our SSH connection… on port 1880. http://scope.local:1880/ You should be presented with a view somewhat similar to this… WELCOME TO NODE-RED! Now let’s get the logic in place for doing some controlling! Open this link: https://gist.github.com/PatchworkBoy/f964c25529611be8448063207143274e Select all of the code, and copy. Now head to Node-Red, click the menu button in the top right corner, and choose Import > Clipboard. Right-click > Paste in the box and hit the ‘Import’ button then finally hit the large ‘Deploy’ button. You should now see THIS: Open a new tab in a web browser, or pick up your mobile connected to the same network as your Pi, and head to… http://scope.local:1880/ui …and behold! A responsive web interface for our motor controller which will work on any mobile device! Use the PWM Sliders to set the motor speed, and the direction switches to set the motor direction. As an added bonus, if you’re a SkySafari user, you can configure it as follows, and the slew and rate buttons will function perfectly - the Node-Red flow I’ve provided also handles the basics of Celestron’s Nexstar Protocol… For USB Gamepad control, you need to connect up your gamepad, then restart the Raspberry Pi. When you return to Node-Red, head to the menu button in the top right corner, and select View > Debug Messages. Your gamepad should be detected towards the top, and should have a message listing it’s VendorID and ProductID (for mine these are 1118 and 39) Note these values down, then double click on the “Gamepad” node… click it’s pencil button, and enter the Vendor ID as VID and the Product ID as PID, and hit the ‘Update’ button… then hit the ‘Deploy’ button in the top right corner of Node-Red. Head back to the web user interface at http://scope.local:1880/ui/, pick up your gamepad, and see if things work! Sadly that’s about as much as we can do with our controller for this year… so I shall see you in 2017 with a fresh pair of encoders, and then we can look at setting accurate tracking rates, adding alignment and GoTo functionality, and possibly integrated guiding via lin-guider. Have a happy whatever-festive-crap-you-celebrate holiday!! I shall be here, with my astro gear, getting downright dirty!
  4. Indeed - I think later down the line the plan will be to continue the project by adding NEMA17 or NEMA23 steppers, and moving the DC motors over to focussing & [filter wheel or camera rotation (that’ll be decided by whether I can ever afford any filters)] At the moment it’s a case of working with what I’ve got! Ultimately the finished project will see the Dob converted to a complete DIY EQ Mount capable of taking the Skyliner 200P OTA + guide scope + camera etc. The GoTo Dob with EQP is somewhat of a middle-ground stepping stone.
  5. Pt3 - aka Setting the Pi up for SSH and headless running!… Blog Version | Pt1 | Pt2 My original intention for this part (as per the above posts) was to cover tapping the optical encoders for positional and directional feedback. The more observant folks out there will also have spotted that there are some extra wires soldered to the pin headers on the DRV8835 in the photo above. Well, it turns out that the LEDs in the encoders are also both dead and need replacing. I’ve got a matching pair of replacements on order from mouser.co.uk, but the next shipment doesn’t hit the country til January. So that’s that plan scuppered for a while. Ignore those additional wires. Their presence will be explained in the future. Instead, we’ll turn our hands to making our Pi run “headless”, and then in Pt4 we’ll look at addressing MANUAL CONTROL! Headless: The Decapitation of Pi Running headlessly means setting our Pi up so that we can operate it remotely over the network - no need to have a monitor or keyboard connected to it! There are a few preparatory steps we need to perform to allow this. This bit should take 30 minutes, tops from start to finish. Get your Pi hooked up to a monitor, keyboard & network, and plugin the 12v PSU that we connected to the DRV8835 board in Pt2. The Pi will boot up and land you at the log in prompt, so as per last time, we’ll use the username: pi and the password: raspberry, and we should then find ourselves at a usable command prompt. Run the following command: sudo raspi-config This is the main tool for configuring the Pi. It should load with option 1 (Expand Filesystem) already highlighted, and look something like below: This expands your Pi to consume all of the SD card that you’ve inserted into it, and we want to do this, so just hit the [enter] key on your keyboard and let it do it’s thang. When it returns to the utility, it should be informing you that it’ll take effect on the next reboot. Just hit the [enter] key again and you’ll be back at the raspi-config menu. Next we need to use the arrow keys on our keyboard to move down to option 7 (Advanced Options) and hit [enter]. Use the down arrow key to highlight option A4 (SSH) and hit [enter]. You’ll be asked if you want to enable SSH. Use the left and right arrow keys to highlight [Yes] and hit [Enter]. Again you’ll end up back at the main menu. We need to make one final change, so shufty back down to Opt 7 (Advanced Options) and hit enter, then shufty down to Opt A2 (Hostname). Hit [enter] on the warning screen, then give your Pi a name - don’t use spaces. I’ve called mine scope for simplicity. Hit [enter] to complete the process, and we’re back to the main menu. Use the left and right keys to highlight [Finish] and hit enter. You’ll be asked if you want to reboot now. Highlight [yes] and hit [enter]. Your Pi should reboot. Wait for it to return to the log in prompt. Now, disconnect your monitor and keyboard from the Pi. Your Pi is now running headlessly! Connecting to the Pi using an SSH Console We still need to enter some manual commands on our Pi. To do so we need to connect to it remotely from a PC or other computer. If you’re on a Mac, or a Linux box with Avahi mDNS installed, you can just pop open a terminal (found in Utilities) and enter the following command (replacing the emboldened scope with whatever you called your pi): ssh pi@scope.local ...so that’s ssh username@hostname.local - it should connect and prompt you for a password (raspberry) If your main PC or Laptop is a Windows-based device, you’ll need to download PuTTy - an SSH Terminal. Once it’s downloaded, run it, then fill in the Host Name as whatever-you-called-your-pi.local Give your Putty connection a name in the “Saved Sessions” box, and hit the [Save] button to the right, then click [Open]. Once you’re at the log in prompt, you can proceed just as though you would have if you still had a keyboard and monitor hooked up. Everything works the same when it comes to linux command line. Log in with the username: pi and password: raspberry Successfully connected by SSH? Whenever you need to connect to your Pi, on windows just run Putty (from your downloads folder, or right click it, make a shortcut and drag that to your desktop) and dbl-click Scope or whatever you saved the session as, and login. On Mac/Linux, just re-enter the ssh command into terminal in the format ssh username@hostname.local Next we need to crack on with getting Node-Red and it’s dependants up and running so that we can start programming the Pi graphically via Node-Red’s web interface from any machine on the network and begin building this monstrosity! I’m separating this out into Pt4.
  6. Looks like the motor feedback part is on hold til January. The HOA0901 doesn't output tach & direction. HAS to be the 0902 for the sake of keeping the code simpler & more resilient. This means the next part (which I should be writing tomorrow) will be covering replacing the Nexstar handset slew/motor functions with a cheap USB game pad & mobile web interface... so I'll be introducing y'all to the mighty Node-RED, then we can get away from the command line stuff for a bit.
  7. EDIT: Scratch that... they most definitely are dead. IR Camera shows diddly-squat. Bum. So, whatever fried the control board and handset popped the optical encoder LEDs also. The motors were all that survived. This makes sense - motors can survive inverted polarity, whereas everything else can’t, so am guessing it’s had a PSU hooked up at somepoint with + to ring and - to tip instead of vice versa. I’ve got two choices: Wait for Mouser to get stock of the HOA0902-011 (http://www.mouser.co.uk/ProductDetail/Honeywell/HOA0902-011/) in January, OR Get the HOA0901-12 from RS which looks to be compatible as a drop-in replacement once it’s had it’s mounting lugs cut off (http://uk.rs-online.com/web/p/slotted-optical-switches/1711830/) The data sheets: HOA0901-012 - http://docs-europe.electrocomponents.com/webdocs/0098/0900766b80098493.pdf HOA0902-011 - http://sensing.honeywell.com/pg_220.pdf I can’t actually see anything different between the two of them really besides price & availability - any suggestions either way electronics folk???
  8. Have a free chuckle on me: spent 3 days now effing n’ jeffing over why I can’t get the integrated red LED to light in either encoder circuit. Turns out they’re both infrared. /me bangs head repeatedly on desk & launches soldering iron across the room
  9. The Hardware… As you can see, we have the Pololu DRV8835-RPI kit, and the Pololu S7V7F5 kit, thus some self-assembly is required. Not shown here, but also necessary, is a 12v DC PSU… 1A seems to be enough at the moment, although later down the line this will all be tailed into the BattBox. A little tip for soldering up Pi Hats… blue-tac is your friend when it comes to getting the PCB sitting square on the multi-pin connector: Anyways, 5 minutes later we’ve got the multi-pin attached, the 3x screw-down terminals, and our 5v step-down converter, and we can plug it on to our Raspberry Pi (a model B+ in this case). Back in Pt1 we broke down the 8 pin wiring loom of each motor/encoder/gearbox assembly… it turns out that the PURPLE wire is the motor’s negative terminal, and the GREY wire is the positive terminal. You can extract the wires from the multipoint connector by pushing in the little rectangular slots with a pin whilst pulling on the related wire. Only extract the ones we need (purple & grey, first 2 from the left), otherwise we end up with exposed metal dangling about near contacts – simpler to leave the rest tucked away in the connector to avoid any moments of idiocy that might let the magic smoke out. So on the blue screw down terminals from left to right in the next picture we have: Motor 2 [-] Motor 2 [+] Motor 1 [-] Motor 1 [+] 12v DC [-] 12v DC [+] Motor 1 hasn’t yet had it’s gearbox re-attached from Pt1. Motor 2 is the complete assembly. That’s the hardware done… now we need to deal with the software to get some basic control up and running. The Software… We’ll go from scratch on this one. I’m going to use the latest Rasbian Jessie Lite installer… which we can download from the Raspberry Pi site. Follow the installation instructions to transfer the image onto a blank SD card (I’m using an 8Gb one for now). This takes 10 minutes, so now’s the perfect time for a crafty cig and a brew, in case you need to recover from the soldering experience! Done? Good. Pop the card into your Raspberry Pi, connect up a network cable, monitor and keyboard, and plug in the 12v PSU. It’ll do some partition resizing and reboot, and eventually you’ll land at the login prompt. The default credentials for Raspbian Jessie are username: pi with the password: raspberry Now we need to install the driver and example software for the DRV8835 First, to download and install WiringPi-Python, run: sudo apt-get install python-dev python-pip sudo pip install wiringpi sudo apt-get install git-core Finally, to download and install the pololu_drv8835_rpi library, run: git clone https://github.com/pololu/drv8835-motor-driver-rpi.git cd drv8835-motor-driver-rpi sudo python setup.py install Running the example program This library comes with an example program that drives each motor in both directions. To run the example, navigate to the drv8835-motor-driver-rpi directory (you should already be there) and run: sudo python example.py TADA! If all has been successful, Motor 1 should spin up forwards then backwards, followed by Motor 2. Our work here for Pt2 is done! In Pt3 I’ll have a look at hooking up the optical encoders so we can start to read the positional feedback, and consider how to get that into an ASCOM/INDI driver that we can use with Sky Safari (or any other planetarium/obs software that supports ASCOM/INDI hardware) SKIP DOWN TO PART 3!
  10. Part 1: What complicated electronicality goes into your average GoTo mount? Answer: Not as much as you’d think! In fact, that’s it. The above picture comprises the entire guts of an early generation (circa 2000) Celestron Nexstar GoTo Mount that accompanied a 90mm refractor scope. This particular example is a dead one, but it’s enough to show us what’s going on. So what have we got there? Let’s break it down… The Control Board Ooohhh… it’s got chips on it. Must be clever. No. Ultimately there are 3x components here that do the work. On the right are 2x XIC0014 oscillators with a 4mhz crystal each. We can summarise their job as: timing. These keep tabs on timing for signals going to and from each motor. On the left in the middle we have a 74HC240D. This is an octal line driver which takes 8 incoming teensy pulse signals and amplifies them into 8 larger pulse signals. In the lower left corner we have an L293DD. This is a part of interest. This is a 4channel H-Bridge motor driver. The pins on the right hand edge are for the hand controller. The pins on the left hand edge are for the Azimuth motor (left & right horizontal motion). The pins on the top edge are for the Altitude motor (up & down vertical motion). That’s a lot of pins for a motor tho… There’s also a MOSFET up top, which will be involved in regulating the incoming 12v DC down to 5v DC to run the electronics. The Handset board Nothing complicated here. It’s an RJ45 socket, mounted on a board along with the 12v power connector. Black & Red are 12v, which goes up to the handset, and across to the controller. The remaining 4 wires carry TTL signals from the handset to the control board. The Motors (x2) The mount contains 2x motors. These are DC controlled, and rely on 2 wires only. So what are the rest of the wires (6x) for? Feedback! Mounted to the rear of each motor is an optical encoder wheel. The black box at the top has an LED mounted in it, pointing at a light sensor. In between these, the wheel passes. Note the slots. The sensor detects the light being blocked and unblocked by the wheel, and converts these into pulses. So there are 2 wires providing Grnd and 3.3v to the LED. The encoder itself outputs one pulse for each slot. This is our speed signal (by counting pulses over a period of time), and by storing the count they can be used for position also. That’s one wire. It also outputs a direction signal. This is a high or low (on or off) signal. If the output is high, the motor is moving forwards. If the output is low, it’s moving backwards. That’s another wire. The encoder circuit needs power… 5v & grnd. That’s another 2 wires, giving our 6. Gearbox… Each motor mounts to a gearbox. I haven’t a clue of it’s ratio, but from the surface dimples we can see that it contains an input gear, which translates it’s motion through 4 other gears, then to the output gear on the other side… …which in typical fashion is smothered with the stickiest cheap & nasty grease known to man. This drives the transmission wheel, which uses a friction plate to move the relevant part of the actual mount. Again, this is liberally smeared in sticky cheap mank. Summary All the control board does is translate signals from the handset directly into drive commands for the motors. ALL the intelligence is in the handset. A bit of diagnosis tells me that the handset for this mount has been fried, along with the control board, but both motors and encoders are in perfect working order, so how can we resurrect this setup? Seeing as all the control board is is a multi channel H Bridge motor driver and feedback sensor board, we can replace the lot with a Raspberry Pi and a few bits. The Raspberry Pi’s GPIO pins can quite happily output 2 channels of PWM to control the motors themselves, and can easily receive 4 channels worth (2 per motor encoder) of feedback pulses. All we need to do is get power to everything. Conveniently, all the bits needed can be picked up for a grand total of sod all (or less) from most robotics hobby places. I already have a veritable mountain of Raspberry Pi boards so I don’t need to acquire one. These cost me £18 each. To hook up the motors, I’ll need a dual channel Pi motor driver board, so I’ve opted for a DRV8355-based kit which can take a 12v DC power supply to run the motors, and with the addition of a 5v step-down board it can also power the Raspberry Pi itself which in turn can power the encoder boards (which also run at 5v). The Pi also provides a 3.3v output which can power the LEDs on the encoder boards. These two components from the provided links total £12.36 inc shipping. Add the cost of the Pi, and that’s £30.36 for a replacement control board.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.