danclarke / WorkingStargateMk2Raspi

Code for Glitch's Working Stargate Mk2 with audio, using Raspberry Pi
GNU General Public License v3.0
36 stars 16 forks source link

Issues with code setup instructions? #3

Open surfrock66 opened 5 years ago

surfrock66 commented 5 years ago

I've had a lot of issues with the code setup. I'm on a Pi 3B+ and a fresh rasbpian buster image.

I've tried the commands as python 2 and 3:

surfrock66@sr66-stargate:~/stargate$ python --version
Python 2.7.16
surfrock66@sr66-stargate:~/stargate$ python3 --version
Python 3.7.3

Here's a breakdown:

1) The link in the instructions to Update the I2C speed of the Raspberry Pi to 400Khz (400000) no longer works for the Raspberry Pi 3B+, something ends up missing and you can't confirm it's set. 2) A package was missing, I had to run this: sudo apt-get install python3-smbus 3) When running main.py, I get the following:

surfrock66@sr66-stargate:~/stargate$ sudo python main.py
Traceback (most recent call last):
  File "main.py", line 3, in <module>
    from Daemon import Daemon
ImportError: No module named Daemon

Not fixed with: sudo apt-get install python3-pip sudo pip install python-daemon sudo pip3 install python-daemon sudo apt-get install python-daemon

Currently pausing but any ideas are appreciated.

surfrock66 commented 5 years ago

Update:

Ran every file through dos2unix. Replaced "from Daemon import Daemon" with "from daemon import daemon" and it worked.

Next, got this error:

  File "/usr/local/lib/python2.7/dist-packages/Adafruit_GPIO/SPI.py", line 42, in __init__
    self._device.open(port, device)

Turns out, I2C and SPI are disabled, enable them in raspi-config under interfacing options.

Next error:

Traceback (most recent call last):
  File "main.py", line 58, in <module>
    httpd_thread = threading.Thread(name="HTTP", target=httpd.serve_forever)
NameError: name 'httpd' is not defined

People think it's an ipv6 issue; disable ipv6 by adding the following to /etc/sysctl.conf

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1
net.ipv6.conf.wlan0.disable_ipv6 = 1

Then type "sysctl -p" I also rebooted. I am getting the same error; still investigating.

surfrock66 commented 5 years ago

EDIT: That was my dumb fault for not commenting out enough of the main.py stuff under web control, I needed to comment 3 more lines out.

surfrock66 commented 5 years ago

My first test (light_control.cycle_chevrons()) worked fine, I have the led's dialed in correct.

The second test, (stargate_control.drive_test()) just results in LED's 7 and 8 (the final 2) blinking on-off 1sec each? Is this a problem with my configuration of the steppers?

surfrock66 commented 5 years ago

Sorry to be asking so many questions; are you powering the stepper hat through the pin header, or are you actually wiring power to the board via the 5-12V power input pins?

surfrock66 commented 5 years ago

Again, answering my own question, you do need to wire power to the steppers. I wired 12V, the motor works.

So I finish the calibration, I can home the gate. The chevron lights blink. Is there a calibration test for the chevron motor, calibration LED, LDR, or ramp lights? I haven't seen life out of them. I am able to use the test from the adafruit library to test sound. When I then run the webserver, nothing happens? Chevrons 1 and 8 go on, and chevron 7 blinks...no buttons do anything, the ring doesn't turn, nothing happens. I see the web request in the python console.

surfrock66 commented 5 years ago

Ok, first thing, my calibration LED isn't lighting, I'll figure that out...I have it working with a pen led for now.

The code for the stargate website 4 hardcoded IP URLs, that needed to be changed. For testing I changed them to 127.0.0.1, at which point I get a popup error "Could not send dialing sequence." Investigating, but any clue as to where to look is appreciated. I get various blinking chevrons, if those equate to error codes I've to know what they mean, I'll try to look in the code.

danclarke commented 5 years ago

Blimey you've been through a lot! The daemon line you can just remove entirely, it's from an earlier revision and just not cleared up. If the Chevrons are flashing, that means at least those are working OK, on first boot if calibration is complete it runs as an approximate clock.

The IPs are in the index.htm, they need to point to the IP address of the Raspberry Pi. The intention is the Pi is used completely headless and you use SSH to connect to the Pi.

There are comments in main.py with regards to first setup. Comment out all of the lines under 'Web Control' and 'Infinite loop', as well as 48 'quick calibration'. Then uncomment line 39. This will cycle through the chevrons do you know which pin each chevron is connected to. Follow the instructions in config.py to set up the pin numbers.

Next comment out the calibration line, and uncomment 42 to try out the various drive modes. You can then set the drive mode in config.py. Continue through main.py until you have a dial sequence working. After that you can then uncomment the web control and infinite loop lines.

As you go through the steps, you should get output to the console with regards to what's going on. Based on the output and what you see/hear you can update the config.py file. If you're using Adafruit stuff for everything and they haven't changed anything (different stepper, etc.) you will probably only need to worry about the cal_brightness, cal_percentage values as well as the chevron pins. The cal_brightness and cal_percentage values come from running the full calibration and noting down the numbers you see.