Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Spazzle
Jul 5, 2003

v1nce posted:

I'm building a kind of self-calibrating stepper-motor controller thingie, and I can already feel I'm going to need an event and timer system, which goes beyond the basic low-level timer libraries. Is there any one good "framework" which provides good implementations of these kinds of things?

I've found 3 or 4 different libs that have varying levels of quality. This just feels like basic stuff that a smart group of people might have done before. Any ideas?

I've maybe been doing something similar using accelstepper. Does this help?
code:
 
#include <AccelStepper.h>

AccelStepper s1(1,22,23);
AccelStepper s2(1,24,25);
AccelStepper s3(1,26,27);
AccelStepper s4(1,28,29);
AccelStepper s5(1,30,31);
AccelStepper s6(1,32,33);
AccelStepper s7(1,34,35);
AccelStepper s8(1,36,37);
AccelStepper steppers[]={s1,s2,s3,s4,s5,s6,s7,s8};
int endstops[]={52,53,44,45,46,47,48,49};
int numaxes =4;
int channel=0;
int route;
long routevalue;
long count=1;
long lastt=0;
long dist;

void setup() {
Serial.begin(115200);
  for (int x=0; x< numaxes;x++){
  steppers[x].setMaxSpeed(500);
  steppers[x].setAcceleration(100);
  pinMode(endstops[x],INPUT);
  }
}

void loop() {
  parseinputcomplex();
  movesteppers();
  framerate();
}

void movesteppers(){
    for (int x=0; x< numaxes ;x++){
    dist=steppers[x].distanceToGo();
    if(dist<0&&digitalRead(endstops[x])==1){
      steppers[x].setCurrentPosition(0);
      steppers[x].moveTo(0);
    }
    if (dist!=0){
    steppers[x].run();
    }
  }
}

void parseinput(){// targets an axis to a set location. Syntax is
[channel value]. Can stack multiple commands.
    while (Serial.available() > 0) {
    channel = Serial.parseInt();
    routevalue = Serial.parseInt();
    steppers[channel].moveTo(routevalue);
    Serial.print(channel);
    Serial.print(" ");
    if (Serial.read() == '\n') {
      Serial.println("go");
    }
  }
}

void parseinputcomplex(){// allows for a broader range of commands
than parseinput. Syntax is [channel command value] ie [0 1 200].
Commands can stack.
    while (Serial.available() > 0) {
    channel = Serial.parseInt();
    route= Serial.parseInt();
    routevalue = Serial.parseInt();

    if (route==0){//Set target position
    steppers[channel].moveTo(routevalue);
    Serial.print("Channel ");
    Serial.print(channel);
    Serial.print(" Target Position ");
    Serial.println(routevalue);
    }

    if (route==1){//move by
    steppers[channel].moveTo(routevalue+steppers[channel].targetPosition());
    Serial.print("Channel ");
    Serial.print(channel);
    Serial.print(" Move By ");
    Serial.println(routevalue);
    }

    if (route==2){//set max speed
    steppers[channel].setMaxSpeed(routevalue);
    Serial.print("Channel ");
    Serial.print(channel);
    Serial.print(" Max speed ");
    Serial.println(routevalue);
    }

    if (route==3){//set  accelleration
    steppers[channel].setAcceleration(routevalue);
    Serial.print("Channel ");
    Serial.print(channel);
    Serial.print(" Accelleration ");
    Serial.println(routevalue);
    }

    if (route==4){//set current location
    steppers[channel].setCurrentPosition(routevalue);
    Serial.print("Channel ");
    Serial.print(channel);
    Serial.print(" Current position set to ");
    Serial.println(routevalue);
    }

    if (route==5){//report status. Channel and value not used. Use
dummy value (such as 0). All distance units in steps.
      for(int n=0;n<numaxes;n++){
      Serial.print("Chn ");
      Serial.print(n);
      Serial.print(" Targ. Pos ");
      Serial.print(steppers[n].targetPosition());
      Serial.print(", Cur. Pos ");
      Serial.print(steppers[n].currentPosition());
      Serial.print(", Current Spd ");
      Serial.print(steppers[n].speed());
      Serial.print(", Current Max Spd ");
      Serial.println(steppers[n].maxSpeed());
      }
    }

    if (Serial.read() == '\n') {
      Serial.println("go");
    }
  }
}

void framerate(){
    if(count%50000==0){
    Serial.print(1000*count/(millis()-lastt));
    Serial.println(" Cycles per second");
    lastt=millis();
    count=0;
  }
   count=count+1;
}

Adbot
ADBOT LOVES YOU

Spazzle
Jul 5, 2003

BedBuglet posted:

So, I have a future project I've started planning out with the bf. Part of the project requires a micro-controller to control 84 transistors (we need to control an array of electromagnets). Is there a good option for handling a dmux of an arduino to that level?

2 megas might work here.

Spazzle
Jul 5, 2003

BedBuglet posted:

I don't think so. The timing is fairly important in that they would have to be in sync to within a second. I had thought about having a mega driving some slave microcontrollers but I was a computer science major, not an electrical engineer so my experience with actually wiring up my own system is middling at best.

Have one mega send data to another. I find that megas run simple programs at khz rates. Subsecond is not a problem. Look up i2c.

Spazzle
Jul 5, 2003

Does anybody have experience with easyiot server?

Spazzle
Jul 5, 2003

Lowen SoDium posted:

Anyone try to power the cheapy Node MCU ESP8266 board on Amazon using 10v on the Vin pin? The silk screening on the back says 10v max, but mine popped and doesn't boot any more when I tried it.

Also, has anyone experiences ordering these ESP8266 boards from Aliexpress? Am I risking burning my house down?

I just power it via usb.

Has anyone had issues using them with wifi on a solderless breadboard? I got constant resets until I moved to another bb. No problem without wifi turned on though.

Spazzle
Jul 5, 2003

Before i go too far down a bad path i'm trying something like this

pH + Temp sensor
v
nodemcu + wifi
v
Raspi
v
Apache server
v
Python script
v
Sqlite database

Looking to make a datalogging system for aquariums with multiple sensor packages on different tanks reporting back to a server on a wifi network. I think I have the whole path working in prototype, but if anyone has any tips or experience that'd be useful.

Spazzle
Jul 5, 2003

Hadlock posted:

ESP8266 (nodemcu) does not have an analog input IIRC which is fine, you can get an ADC device to do the conversion for you.


It has one adc channel.

Spazzle
Jul 5, 2003

rawrr posted:

Just in case you hadn't considered it, it seems like this would be a simpler option: https://hackaday.io/project/5797-plotly-esp8266


Stuff like that looks convenient, but I'm worried about 2 things. Permanence and scalability. Eventually this system might go to ~30 nodes dumping 2+ sensor data each every hour. I want to have complex custom visualization for that without having to pop between plots. Additionally at some point most of these services charge for use based on data writes. And I don't want to be tied to a platform that might go dark or change arbitrarily in a year.

Spazzle
Jul 5, 2003

I'll check it out. Looks like I can run my own thingspeak server anyways. Do you know how well it works with multiple simultaneous data visualizations?

Edit: it looks like it can output different data sets on a single channel. I'm wondering how you can visualize the same kind of data across multiple channels simultaneously. Like show temperature from several channels in the same plot.

Spazzle fucked around with this message at 16:14 on May 30, 2016

Spazzle
Jul 5, 2003

Mr. Despair posted:

I've got the same sorta deal going, I use highcharts (well, technically highstocks but that's just to get the timeline functionality) to display different things from the mysql database I have.



http://www.highcharts.com/ It's free for personal use, pretty great stuff, can scale it up really well, my experiment uses it and we've got a page with ~10 things on three different plots that are all synced to the same timeline widget. Do need to fix the positioning of the legend and add the rest of my sensors though...

As far as getting the data there, I just have an arduino with an ethernet shield, and I have some php sitting on my website that waits for GET requests from the arduino that filters things into the database. Could do the same thing over wifi too, doesn't matter where the request is coming from really.

Yeah, this is pretty close to what I'm thinking. I have a chain basically working now. Just need to create charts from stored data. Probably use python scripting.

Spazzle
Jul 5, 2003

Mr. Despair posted:

If you can output your data in JSON format I'm willing to bet that highcharts will make nicer looking plots with less work than any python based stuff.

Was initially worried about the license stuff, but seems ok. It does look slick.

Spazzle
Jul 5, 2003

COOL CORN posted:

Why isn't my LCD doing anything? :saddowns:
code:
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  lcd.begin(16, 2);
  lcd.print("hello, world!");
}

void loop() {
  lcd.setCursor(0, 1);
  lcd.print(millis() / 1000);
}


Does it light up and/or change when you adjust the potentiometer?

Does it require 5 volts?

Spazzle
Jul 5, 2003

Acid Reflux posted:

Anyone have any favorite neopixel tutorials? I got a bunch of the little individual ones on round PCBs to play with, but everything I've come across so far seems to want to teach me how to use whole strips. My programming skill level without just cribbing code is roughly "hello world", so the more toddler-oriented the material is, the better.

The strips are just individual ones linked together. I think you can actually cut singles off and use them.

If you really only want one pixel you could set the strip length to one.

I also prefer the fast led library. If I recall the default neopixel library was laughably slow.

Spazzle
Jul 5, 2003

babyeatingpsychopath posted:

I was using the fast LED library for strips, but now I've got some panels. Is there an equivalent to fastLED for neoMatrix?

I haven't used NeoMatrixes before. Looking at the adafruit page brieflly (https://learn.adafruit.com/adafruit-neopixel-uberguide/neopixel-matrices) it implies to me that it behaves like a strip that happens to be arranged in a 2d pattern. That is, if you had a 16x16 array of 256 pixels, it could be addressed as a 256 pixel strip, where it just goes to a new line every 16 pixels, or some such depending on the toplology. If that is the case, the fast led code would probably be equally applicable. Just figure out how pixel number maps to array position.

Coincidentally, I did just order a bunch of these (https://www.adafruit.com/product/2277) to drive off a raspi. I'll see how much of a boondoggle they are.

Spazzle
Jul 5, 2003

Parts Kit posted:

It may just be me or the combo of stuff I was using on a past project but Adafruit's libraries seem really bloated.

I recall watching the output of both on my oscilloscope, and the neopixel bits were just way longer. Long enough that it cut into the frame rate with big chains. The fast led output was basically as short as could be dumped out of arduino.

Spazzle
Jul 5, 2003

Sockser posted:

This is probably the thread for this
Bit of a seizure warning on the video though

https://www.youtube.com/watch?v=ihJoaqTi790

Context: each set of two digits is a 45 neopixels strip, running approximately right to left, have run it off an Uno, an Adafruit micro, and currently a Metro Mini

I just replaced the strip in digits 6+7 because it was doing the same thing, though I was able to avoid it by turning off the pixel where it looked like things were loving up

I’m running on a 5v, 10A power supply, with power and ground running roughly to the middle of each strip

Possibilities off the top of my head-
1. It’s actually a bad strip in digits 7/8, it’s just cascading to the middle of the next strip instead
2. Maybe I got some 2811s mixed in with my 2812s

E: and it does the same with the neopixel library or fastled
I possibly had the same problem. I had a bunch of programable pixels strips running off of a battery which outputs 5v for the LEDs and 12 volts USB to run an arduino that was controlling them. What I think happens is that when enough LEDs turn on, the relative ground levels shift and the data signal no longer works. I had to tie the led ground to the arduino ground to fix it.

Spazzle
Jul 5, 2003

Sockser posted:

Having trouble googling what I want here

I have built some basic FFT visualizers out of a raspi, like, raspi is running audio and visualizing it

What I want to build, via some flavor of arduino, is a board that will accept a 3.5 audio in and then let me process that, but I can only find audio output boards, or schematics that use a microphone rather than a direct line in. Is there some sort of arduino breakout that exists that will just let me do the thing I want without having to build out my own circuit for this?

Maybe this? I use it with the led controller it was designed for, but it can be used separately. https://www.tindie.com/products/electromage/electromage-pixelblaze-sensor-expansion-board/

Adbot
ADBOT LOVES YOU

Spazzle
Jul 5, 2003

wolrah posted:


I know this is way late for your target of Halloween on this particular project, but if you are interested in building these sorts of things in general and want to animate them I strongly recommend that you get to know addressable LEDs. WLED firmware on an ESP32 takes literally minutes to set up from unboxing the hardware to animating LEDs and gives you a nice web interface that's even mobile friendly to control it from (as well as support for basically every network automation protocol you might want).

Addressable LEDs are not always the right answer but they're cheap and easy enough these days that they can be used to brute force a solution for less mental effort than doing it what might be the absolute most cost or power efficient way.

I haven't looked too deeply into WLED, but aren't you basically stuck using premade patterns unless you stream pixel data from external sources? I'd usually use fast LED on an Arduino or use a pixelblaze if I wanted a custom pattern.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply