Skip to content
Snippets Groups Projects
Commit de884b99 authored by Krisjanis Rijnieks's avatar Krisjanis Rijnieks :lion_face:
Browse files

Add part about Python and mods

parent 22ccf3ee
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,11 @@ The cobra project... Starts here...
## Programming with EDBG Atmel ICE
Once you have your [hello.serial-UPDI.FT230X](http://academy.cba.mit.edu/classes/embedded_programming/index.html#programmers) or [hello.CMSIS-DAP.4.D11C](http://academy.cba.mit.edu/classes/embedded_programming/index.html#programmers) ARM programmer board ready, use [EDBG](https://github.com/ataradov/edbg). Clone it with `git`, install dependencies and run `make all` to compile it. It will produce an executable `edbg` in its home folder. If you have an Atmel ICE with the board connected, use a modified version of the command below to program the ARM board.
Once you have your [hello.serial-UPDI.FT230X](http://academy.cba.mit.edu/classes/embedded_programming/index.html#programmers) or [hello.CMSIS-DAP.4.D11C](http://academy.cba.mit.edu/classes/embedded_programming/index.html#programmers) ARM programmer board ready, use [EDBG](https://github.com/ataradov/edbg). Clone it with `git`, install dependencies and run `make all` to compile it. It will produce an executable `edbg` in its home folder.
> **On Mac** you might have a missing dependency `libhidapi`. Install it with `brew install hidapi`.
If you have an Atmel ICE with the board connected, use a modified version of the command below to program the ARM board. This assumes that you have added the EDBG repository to your path.
```
edbg -t samd11 -bpv -f free_dap_d11c_mini.bin -s J41800032510
......@@ -45,21 +49,68 @@ edbg -t samd11 -bpv -f free_dap_d11c_mini.bin -s J41800032510
`-s` stands for the serial number of your programmer.
`-f` stands for the binary file that you want to flash to your chip.
You can download the [bin file here](http://academy.cba.mit.edu/classes/embedded_programming/SWD/free_dap_d11c_mini.bin)
### Serial Number
You can tell the serial number of your programmer as follows.
**On Linux** use `dmesg` command.
**On Mac** use `lsusb` command.
**On Mac** use `lsusb` command. Use `brew install lsusb` in case you do not have it.
Try to disconnect your programmer, run the command, connect it and run the command again to compare the output and find the correct device and its serial number.
## Mods and MDX-20
## Mods, Python and MDX-20
We have been using the original USB cable for the MDX-20 at the KSUM Fab Lab. To be able to drive it via `mods`, we use the DSR/DTR mode. In order to be able to use that, we need to use the Python server.
It does not matter if you use the MIT or COMMUNITY version of Mods. Both have a file called `py/pythonserial.py` that should be used. First check your `python3` installation. It should come together with `pip3`. To install it and needed Python dependencies do the follwing.
**On Mac**
```
brew install python3
brew postinstall python3
pip3 install pyserial
pip3 install websockets
```
**On Linux (Ubuntu)**
We use `sudo` here to avoid the server not being able to access the serial port.
```
sudo apt install python3
sudo apt install python3-pip
sudo pip3 install pyserial
sudo pip3 install websockets
```
**Run the server** with the following command. Use `127.0.0.1` as the address and port `1234`. These values you will need to use in the Mods interface later (they are there by default, but in case you want to use your own numbers).
```
python3 py/pythonserial.py 127.0.0.1 1234
```
Server should be running now. The rest of it is running Mods in your browser. Refer to [instructions](https://github.com/fabfoundation/mods#running-mods-locally-in-your-computer) on the community repository of mods.
> Replace the `serial` module with `pyserial` in the community version of mods.
Make sure you know the device identifier of MDX-20 your computer assigns to it. To find it out, use the following.
**Mac**
```
ls /dev/tty.*
```
**Linux**
```
ls /dev/ttyUSB*
```
We have been using the original USB cable for the MDX-20 at the KSUM Fab Lab. To be able to drive it via `mods`, we use the DSR/DTR mode. In order to be able to use that, we need to use the Python server.
Enter the device identifier into the **serial device** part of the Mods serial module. Use 9600 as the baud rate. Press the **open** button. You should see a port open message.
To be continued...
If you hit the **move to origin** button in the **Roland MDX-20 milling machine** module, the machine should move to the supplied coordinates.
## Motor Control
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment