README.md 7.28 KB
Newer Older
Jake Read's avatar
Jake Read committed
1
# RNDMC
Jake Read's avatar
Jake Read committed
2

Jake Read's avatar
Jake Read committed
3
4
5
**Reconfigurable Numeric Dataflow Machine Controller**

*aka project 'consistent-sandbox'*
Jake Read's avatar
Jake Read committed
6

Jake Read's avatar
Jake Read committed
7
8
![img software](doc/images/atkapi.png)
![img hardware](doc/images/machine-with-atkapi.jpg)
Jake Read's avatar
Jake Read committed
9

Jake Read's avatar
Jake Read committed
10
11
12
13
14
15
This is a piece of software that is designed to help you assemble high level controllers from dataflow software elements. It serves a graphical programming interface, and is meant to live with dataflow hardware elements from [this project 'automatakit'](https://gitlab.cba.mit.edu/jakeread/automatakit).

It's in the early stages, so bear with us. Everything is going to be great. 

# Usage 

Jake Read's avatar
Jake Read committed
16
## Installing Node.js, WebSocket and SerialPort
Jake Read's avatar
Jake Read committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

To Run DMC, you'll need to install node.js, and then the packages serialport and ws (websocket).

## Install Node.js

Node.js is a runtime environment for javascript, so you can write and run js locally. [Download and install it here](https://nodejs.org/en/download/). 

To check that node is installed, you can use

``node -v``

In Windows check that in *Environment Variables, System Variables, Path* there is a path for C:\Users\yourusername\npm folder. If the folder does not exist, create it and set the path.  

## Install Serialport

Node comes with a package controller called 'npm' - node package manager. You can use this to install dependencies for node programs. 

Serialport is a package for node that allows it to interact with a hardware serial port.

Navigate to the directory where you'll be running from (atkapi). Do

``npm install serialport``

## Install WS (WebSocket)

WebSockets are very simple web connections. We use them to chat between the 'server' / heap (node) and the 'view' (your browser).

To install ws, do

``npm install ws``
Jake Read's avatar
Jake Read committed
47

Jake Read's avatar
Jake Read committed
48
49
50
# Running DMC

To run the program, we launch the main.js file with node, from the command line. One of the things this does is run a tiny HTTP server that we can use to access the UI.
Jake Read's avatar
Jake Read committed
51

Jake Read's avatar
Jake Read committed
52
53
54
55
56
57
cd to the rndmc folder and run: 

``node main``

It's handy to keep a terminal window open beside a browser when running the software - it's not perfect yet - I do this:

Jake Read's avatar
Jake Read committed
58
![term](doc/images/termopen.png)
Jake Read's avatar
Jake Read committed
59
60
61
62
63
64
65
66
67
68

This way I can watch for errors, and restart it when it crashes. Hopefully not a lot of this will happen.

## Open a Browser

The program is now running a tiny HTTP server, where it will deliver an interface. It's set to show up at your local address on port 8080.

In a browser open *localhost:8080* you will see the mods and this msg in the terminal *SEND PROGRAMS TO UI* 

## Using the Browser Interface 
Jake Read's avatar
Jake Read committed
69

Jake Read's avatar
Jake Read committed
70
![img moving](doc/images/mothermother.gif)
Jake Read's avatar
Jake Read committed
71

Jake Read's avatar
Jake Read committed
72
73
74
 - those GIFs tho 
 - steppers gotta step 

Jake Read's avatar
Jake Read committed
75
76
77
78
79
80
81
82
83
 - load a program
 - drag around
 - zoom in and out 
 - add a module
 - hook events up
 - rm events
 - rm modules
 - change settings 

Jake Read's avatar
Jake Read committed
84
85
# Writing New Modules 

Jake Read's avatar
Jake Read committed
86
87
 - whenever a menu is requested, the system searches ```modules/ * ``` for *anything*. include your .js of a new module there 
 - anything goes: you can run whatever code will run in node.js ... just follow these simple rules 
Jake Read's avatar
Jake Read committed
88
89
90
91
92
93
94
95
 - TODO: put example here, with comments 

# Writing Hardware Modules 

 - TODO: same, also including links / explanation to atk 

# Development Notes 

Jake Read's avatar
Jake Read committed
96
97
## For MW

Jake Read's avatar
Jake Read committed
98
99
100
101
- title is still 'xperiment'
- do hw if you can, and gifs / demo at the same time?
- some example program 
- example modules 
Jake Read's avatar
notes    
Jake Read committed
102

Jake Read's avatar
Jake Read committed
103
104
- add reset button to hardware
- add router for reset, test 
105

Jake Read's avatar
OK    
Jake Read committed
106
## Documentation
Jake Read's avatar
notes    
Jake Read committed
107
- GIFS
Jake Read's avatar
Jake Read committed
108

Jake Read's avatar
Jake Read committed
109
## Questionable Moves
Jake Read's avatar
notes    
Jake Read committed
110
- module deletion seems unclean 
Jake Read's avatar
Jake Read committed
111
 - input / output objects should be able to unhook themselves: 
Jake Read's avatar
notes    
Jake Read committed
112
 - keep references of what-is-attached ? 
Jake Read's avatar
Jake Read committed
113

Jake Read's avatar
Jake Read committed
114
115
## WRT Representations

Jake Read's avatar
OK    
Jake Read committed
116
OK, should write this out properly at some point.
Jake Read's avatar
Jake Read committed
117
118
119
120
121
122

Module have 
 Inputs
 Outputs
 State (initial states are settings)

Jake Read's avatar
notes    
Jake Read committed
123
124
125
126
127
Hardware Modules have
 routes
 connected to 
 links 

Jake Read's avatar
Jake Read committed
128
129
130
131
132
133
Also
 Names, IDs
 Paths-to-source 

To assemble a representation of these, we want to have a kind of 'netlist' that, for convenience, we'll treat like a JSON object. We want heirarchy, so consider the representation having 'top-level' outputs / inputs / state as well ? 

Jake Read's avatar
Jake Read committed
134
## Programming Notes
Jake Read's avatar
Jake Read committed
135

Jake Read's avatar
Jake Read committed
136
137
138
139
### 15 Minute Tasks 
 - @ views.js, uiRequestModuleMenu and uiRequestProgramMenu don't properly build trees from folder structure. similarly, reciprical fn's in client.js do the same 
 - @ these load / save functions could also reach into the modules' source to retrieve their proper names, as spec'd in description ... 
 - 's' for save program uses hack-asf DOM alert to ask for path
Jake Read's avatar
Jake Read committed
140

Jake Read's avatar
notes    
Jake Read committed
141
## Desires 
Jake Read's avatar
Jake Read committed
142
- heirarchy zoom 
Jake Read's avatar
notes    
Jake Read committed
143
 - architectural clarity betwixt UI and Heap 
Jake Read's avatar
Jake Read committed
144
145
146
147
148
149
150
- states / uis / etc - one off / one-at-a-time for updates 
 - i.e. all f'n update calls are to single module-global state update
 - ! 
- states / getters / setters not applicable to sub-elements in an object within state
 - i.e. array access 
- consistent dereferencing, type checking implementation?

Jake Read's avatar
notes    
Jake Read committed
151
152
153
154
155
156
157
## UI Desires
- modules have visual ways to throw errors - i.e. flashing red, popping up... 
- off-screen divs get pointers-to so that we don't get lost
  - 'h' or something to zoom-to-extents
- better module menu
- hover for alt descriptions 

Jake Read's avatar
Jake Read committed
158
159
## Planner Bugs
 - trapezoid linking doesn't account for speed changes properly, i.e. doesn't ramp down into next move if next move's cruise speed is less than our exit speed 
Jake Read's avatar
notes    
Jake Read committed
160
 - should have some stronger ideas about flow control, allowable segment size (based on time) 
Jake Read's avatar
Jake Read committed
161

Jake Read's avatar
notes    
Jake Read committed
162
## Want 
Jake Read's avatar
Jake Read committed
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
- log() for logs-from-module tagged 

## Demo Desires 
- want to show immediacy of hardware: software representation
- want to show physical reconfigurability and software reconfigurability
 - i.e. mill, add rotary tool, pull normal vector from planner moves and route to r motor 
- want to have UI elements
 - button, terminal, 
- live motor torque display, vector from accelerometer 

## Network Desires
- c improvements / dma etc, would be very cool
- flow control probably desired ... what can we model with uart and implement with fpga?
- proper speed tests
- DMA not possible / not enough channels for router implementation / not portable enough ... 
- lights displaying activity

## Bugs
- cannot connect input to output w/o backwards bezier 
Jake Read's avatar
Jake Read committed
182
- when source has changed, opening programs that have references to that source should be carefully done ... 
183

Jake Read's avatar
Jake Read committed
184
185
# The RPI

Jake Read's avatar
Jake Read committed
186
187
188
189
One of the desires here is to run programs headlessly on small embedded computers like the Raspberry Pi. The router has pogo-pins for this, so that when it's mounted beneath a Raspberry Pi the USB and Power lines are automatically hooked up - the 2A Buck Converter on the Router can also be used to power the RPI, so it can all run on one DC power bus. Nice! 

![ATKRouter](https://gitlab.cba.mit.edu/jakeread/atkrouter/raw/master/images/atkrouter.jpg)

Jake Read's avatar
Jake Read committed
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
### Setup the Raspberry Pi

 - [download raspbian](https://www.raspberrypi.org/documentation/installation/installing-images/README.md)
 - [flash and boot, setup etc](https://www.raspberrypi.org/documentation/setup/)

### Install Node on the Raspberry Pi

 - to install node, download the distro you want from nodejs.org 
 - extract the files, and hit these commands

navigate to the distribution
`` cd <distro> `` 
copy that to local space on the pi
`` sudo cp -R * /usr/local/ ``

to check that node is installed, check the version using
`` node -v ``
which should return the version number of the distro you installed.

Jake Read's avatar
Jake Read committed
209
210
However:

Jake Read's avatar
notes    
Jake Read committed
211
``` need to figure out how to get the RPI serialport to talk ``` 
Jake Read's avatar
Jake Read committed
212
213

- https://cnc.js.org/ 
Jake Read's avatar
Jake Read committed
214
215
216
- https://github.com/cncjs/cncjs/wiki/Setup-Guide:-Raspberry-Pi-%7C-Install-Node.js-via-Node-Version-Manager-(NVM)