Gettin Back Goin on FPGA

I recently bought a high speed AD/DA unit which seems like it could probably only be serviced by an fpga, so I thought I’d give it another go.

I have this board

and a

To program it

I power it by jumpering the labelled 3v3 to an arduino’s 3v3 power. It’s just the easiest way for me. A random power supply will porbably work too. Looks like it has an onboard regulator

Unfortunately my working Quartus II is on long gone computer

After a couple days I figured out that I downloaded the wrong version. Make sure to get the web edition

Get the main Quartus file and the cyclone II support

Quartus II kept crashing found this fix

quartus: error while loading shared libraries: cannot open shared object file: No such file or directory

sudo apt-get install libsm6:i386

In the new project wizard pick a new and for the device pick

Device Cyclone II


Couldn’t find that exact part number in the list. Picked EP2C5T144C8

Seems close.

So we have to do pin assignment. The clock is a special pin, so that’s how you pull it in. There are leds on board

Three LEDs are connected to pins 3, 7 and 9, and a push-button is connected to pin 144.

I took called the node clock and used PIN_17 which desribes itself as one of the clocks.

I picked counter_out[25] as PIN_9 since it gives a reasonable blink rate. (the clock pin should be 50Mhz)

Click new file vhdl. Made a simple counter.

// This is an example of a simple 32 bit up-counter called simple_counter.v
// It has a single clock input and a 32-bit output port
module simple_counter (input clock , output reg [31:0] counter_out);
always @ (posedge clock)// on positive clock edge
 counter_out <= #1 counter_out + 1;// increment counter
endmodule// end of module counter


Got an error about needing a Top Level Design entity

Went into Assignments > Settings to set the top level design entity. I guess this is like defining the entry point of the program. Used simple_counter as top level.

The “My First FPGA” tutorial has too much bullshit in it from the get go.


Tools > Programmer

Hardware Setup – picked USB Blaster


Having porblems. Just says failed.

Picked .sof files in output_files

Error (209053): Unexpected error in JTAG server — error code 89

Apparently some kind of permissions problem in linux for the usb blaster

Holy shit. It is working.

It assigned counter_out[0] to PIN_24. And I read a 25Mhz signal. That makes sense. Every cycle of the 50Mhz clock the pin is flopped and that divides the frequency by 2.

Magnet Sensor arduino

 I got da


It good?

It 1.0-1.6 mV/G sensitivity

oh I pooed

Front is cornered side.


1 is power

2 is ground

3 is signal

left to right.

1 T = 10000G

Positive magnetic field pointing into the front face of the device.

Negative magnetic field is pointing out from front face of device


const int analogInPin = A5;  // Analog input pin that the potentiometer is attached to

int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)

void setup() {
  // initialize serial communications at 9600 bps:

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);            
  // map it to the range of the analog out:
  // 1.3mV/G * 2500mV full range = 3250
  outputValue = map(sensorValue, 0, 1023, -3250, 3250);  
  // print the results to the serial monitor:
  Serial.print("sensor = " );                       
  Serial.print("\t B Field = ");      

  // wait 2 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:


Why have I written this like I’m a fucking idiot? FOR SOME SPICE. I’M A FREE SPIRIT.


A single little button cell looking magnet maxes out at 2950G when placed right up against the thing.

I would guess that this is about right though.

This value probably cannot be trusted. The snesor states that it goes nonlinear towards saturation

Maybe 1cm away the value is already reduced to 200-300G.

A stack has 700-800G at same position.

A stack caps out the meter with still .3cm left.

The field ramps up very quickly.

I couldn’t venture really how strong the field is at the surface of the stack, but it’s more.

I need to build some kind of apparatus. Maybe I can see what kind of power law we’re talking.


Orange pi

So I finally got the orange pi running.It hasn’t been hard, it just has not been a priority.

I bought one months ago when I saw it on hackaday for 15$. Took a month or so to arrive. Then I realized it has kind of a weird power adapter port (not powered by usb like the raspbery ) so I bought one of those and that took a bit.

I went to a sketchy chinese website and downloaded the image for the “orange pi pc” Lubuntu.

I don’t know why I picked lubuntu now, but seems like a reasonable choice.

Clicked on the image on my ubuntu box and brought up a disk image program that let me install on the orange pi.

Popped the sd card in that bad boy. Booted right up. Can ssh into it with user orangepi, password orangepi.

Updated all the crap.

Installed nodejs and npm using apt-get install and symlinked (sudo ln -s )node to nodejs.

It all seems fine. Pretty Neat.




High Speed DAC Aliexpress

I bought this bad boy. Seems cool. Thought maybe I could brute force my way into AM radio land with it.

Also a good project for fpga. Microcontrollers are going to be too slow.

A noticeable problem is the missing of the pinout

AD:DA pinout

This appears to be the same product and I can at least confirm that this pinout does work for the DA side of things.

I wrote a quick test program to service it with a ramp function with an arduino. Good idea to sanity check before diving into the deeper waters of fpga.


IMG_0143 2Ripping through the arduino code with no delay makes a ramp at 53.2Hz. Pathetic, but working.

#define CLKPIN 2 
//Lowest bit pin on 6, highest bit on 13

void setup(){
  pinMode(CLKPIN, OUTPUT);
  digitalWrite(CLKPIN, HIGH);
  for(int i = 0; i< 8; i++){
    pinMode(13-i, OUTPUT);
byte count = 0;

void loop(){
  digitalWrite(CLKPIN, LOW);
  for(int i = 0; i < 8; i++){
    digitalWrite(6+i, count & (1 << i));
  digitalWrite(CLKPIN, HIGH);





Root Beer ONE


Root beer go.

40g Sarsparilla

40g Sassafras (the good shit)

1 vanilla bean split and scraped

1L water

10g birch bark (This is tree)

start boil 4:33

turned off heat 4:53

5:04 it is awful

fill with water up to 1L

220g sugar


Also Is known carcinogen

“I like the initial flavor but then it feels like I have a tree in my mouth. It evens out into stick.” – Judgeful Beth

Maybe we should transition into the ice cream business


We’re trying to detect a green laser and having problems. One problem is that the laser is so goddamn bright that it is saturating the camera. Maybe that be nice except that the ligthbulbs in the background are doing that too.

Some useful little mini programs:

Capture and image and save it.

import cv2
import numpy as np
import time

cap = cv2.VideoCapture(0)
print cap.get()
_, frame =



This let’s us poke around on an image and print out the data corresponding to a point.

import cv2
import numpy as np
import time

cap = cv2.VideoCapture(0)

_, frame =

def checkStuff(event,x,y,flags,param):
    print "yo"
    print event
    if event == cv2.EVENT_LBUTTONDBLCLK:
        print frame[x,y,:]
    if event == 0:
        print frame[y,x,:]


The HSV decomposotion from the tutorials is ok, but  not cutting the mustard.

Maybe something more autocorrelationy?

So I get the python side, and I was giving the C side a go.

Apparently the recommended way is to use Cmake to make your projects. I don’t like it.

Kind of fell off the bandwagon on this one. Would be better to actually get something working in python before going onto this.


Raspberry Pi

Scan the network for a ip that shows up

nmap -sn

log in with ssh. You need (hypothetically I’ve heard tale of other ways, but just do this. You have a monitor. So much easier) to boot once with a monitor to set the ssh server on bootup.

ssh pi@

password: raspberry

setting up wifi

iwlist wlan0 scan

Jesus, had to update everything.

sudo crontab -e

@reboot sh /home/pi/bbt/ >/home/pi/logs/cronlog 2>&1

Ran into this issue. Needed to update npm.

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

network={ ssid=”WORK” key_mgmt=NONE wep_key0=PASSKEY }

Ran into massive pyserial problems. I don’t get it. Apparently the solution wast o change from the ubuntu repository version to the pip installed versions of pyserial

Bought a cheap aliexpress display. This worked:

Folgertech prusa update

SO, it turns out we’ve been printing mirror images of parts somehow. We just printed raspberry pi cases and they don’t fit. I suppose we had been printing parts that are too symmetrical to observe this before.

What’s extra bizarre is this makes the coordinate system of the printer not right handed. Now the maximum of x is towards the power supply side.

We played with some stuff in the marlin configuration file

Removed the #define disable_max_endstops line

#define INVERT_X_DIR true

#define X_HOME_DIR 1

Seems ok now.

Writing a WordPress sketch Plugin: Mr. Sketchy-Poo

So I want to make a plugin that allows me to make quick sketches on my posts.

First I’m going to install a local wordpress on my comp to work with.

Turns out I didn’t have mysql installed

brew install mysql


mysql.server start
mysql -uroot


CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress';

Probably might want to pick a different password or whatever.

GRANT ALL PRIVILEGES ON wordpress . * TO 'wordpress'@'localhost';

Following 5-minute setup guide.

cd into the wordpress folder. Run the following to make a server at in the unzipped wordpress folder

php -S -t .

Changed wp-config-sample.php to wp-config.php

and put all my passwords and stuff in there



So I found this script

$db = @mysql_connect('', 'wordpress', 'wordpress');
if (!$db) echo "connection failed";
else echo "connection succeeded";

and ran it.

Turns out need to replace localhost with

I don’t know why. Whatevs.

Smooth sailin.

Made my username wordpress and password wordpress. Don’t host this for real.


Installing something by going to a webpage is so goddamn bizarre. I feel like I’m in 1995 or some shit.

php sickens me.

It’s fun being a snob! ^o^


Here’s some useful looking links

Okay so the first one seems good but its antiquated

Led me here.

The way buttons are made in tinymce has changed. Check out the new way.


I had some trouble getting the mouse to actually draw where it should. I ended up using a recursive travel up through the page to add up all the offsets as seen here.

The approach I decided to go with was making a seperate php file that the jquery request will post the image data to.

the wordpress function media_handle_upload can be called on the server side.


I didn’t realize how hat i also needed to include wp-load.php from the example and was getting weird __() can’t be found kind of errors.

This was helpful in packing the images into blobs and the forms in a way that wordpress likes.

The jquery ajax is quite particular. Apparntly you need to include the lines

				type: 'POST',
				contentType: false,
    		processData: false,

				success: function(data){
					var mytext = "<img src=" + data + "/>"
					tinyMCE.activeEditor.execCommand('mceInsertContent', 0, mytext);

contenttpye false, processdata false in order for it to work.

I just took a wild stab at inserting the image with the img tag and it seems ok.



Find it at



Chinese Arduino Problems on Mac

Followed instructions here. You need some drivers.

Remember to run that weirdo kext command before you restart

For some reason I couldn’t get it to work the first couple times.

I needed to change the symbolic link a little. The thing arduino could actually see was cu.wch. not, so just replace it with that.