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
Sweevo
Nov 8, 2007

i sometimes throw cables away

i mean straight into the bin without spending 10+ years in the box of might-come-in-handy-someday first

im a fucking monster

ol qwerty bastard posted:

maybe i'll include an arduino and some blinking LEDs :haw:

no, you need one arduino per fan, and an ethernet shield for each so that they can communicat with another arduino that blinks the LED

Adbot
ADBOT LOVES YOU

ol qwerty bastard
Dec 13, 2005

If you want something done, do it yourself!
it'll automatically tweet the internal temperature of the car every 4 minutes too

Luigi Thirty
Apr 30, 2006

Emergency confection port.

no you need a cell phone shield so you can dial up the other Arduino like it's an alarm system from 1977

Bloody
Mar 3, 2013

Bloody posted:

arduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduinoarduino

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Sweevo posted:

decade counter?

that's it now i can use this 555 for something

echinopsis
Apr 13, 2004

by Fluffdaddy
my arduino has allowed me to get into this stuff without having to do too much theory first. some would say that is lovely and I don't belong doing it. maybe that is correct

but I LNOW that I have not only made blinking LEDs but also leds that fade in and out, and none of this triangle wave poo poo for amateurs but on a sine wave. it is cool fun


ps what's te most efficient way to do that. I was using trig from a counter to get value. I mean it works fine but like a triangle wave is sunstaontlly more efficient to calculate, is there a quicker way to calc a sine wave?

Corla Plankun
May 8, 2007

improve the lives of everyone
lookup table is pretty efficient i think

ol qwerty bastard
Dec 13, 2005

If you want something done, do it yourself!
shouldn't a fading led be done with pwm anyway?

that's where an arduino would really shine, since building a continuously varying pwm circuit from discrete components would be annoying as rear end

echinopsis
Apr 13, 2004

by Fluffdaddy

ol qwerty bastard posted:

shouldn't a fading led be done with pwm anyway?

that's where an arduino would really shine, since building a continuously varying pwm circuit from discrete components would be annoying as rear end

yeah it was

but the duty cycle was based off a sine wave

Corla Plankun posted:

lookup table is pretty efficient i think

oh yeah... ill need to LOOKUP how to make one

Bloody
Mar 3, 2013

matlab -> sin(0:2*pi/256) -> copy-paste to array -> iterate through array w/ char

Bloody
Mar 3, 2013

if u want sin() the function then make a 360-element lut

Bloody
Mar 3, 2013

if ur doin a controls thing and you wanna approximate sin and cos for small changes in angle just approximate them as 0 and 1

Luigi Thirty
Apr 30, 2006

Emergency confection port.

okay, ordered decade counter and components to build my own external timer circuit instead of doing it in the arduino. :toot:

too many wires aaaag

https://www.youtube.com/watch?v=0FOw4f1_AeU

i'm cheating and padding the string with 4 spaces :saddowns:

Captain Cool
Oct 23, 2004

This is a song about messin' with people who've been messin' with you

echinopsis posted:

yeah it was

but the duty cycle was based off a sine wave
don't do trig on a microprocessor, it's horribly expensive (ms of time if you're lucky and kb of library code)

you should be able to walk along parabolas and get plenty close for visual effect

brightness = 50%
slope = 10
loop:
brightness > 50%? slope-- : slope++
brightness += slope
wait

might want to reset parameters at the 50% crossing to keep errors from accumulating but that's the idea

Woolwich Bagnet
Apr 27, 2003



posted about it before but anyone wanting to do things more complicated than blinking LEDs or w/e should look in to these http://www.cypress.com/?rID=78840&source=psoc

a bit pricier than an arduino but leagues more functional. build in adc (12 and 20 bit), current and voltage dacs, op amps, counters, usb support, spi, i2c, serial, etc. components are added with an easy to use schematic format where you drag and drop them on to it. then you can code the functionality in C++, using their free IDE. the libraries for things like spi etc are included in the ide so you dont need to mess with them.

you can pick up a full pinout one here for $75 http://freesoc.myshopify.com/products/freesoc-development-kit

there's tons of examples in the ide, and each component has a pdf of the datasheet for that component with information on how it functions, as well as the API for it.

you can download the ide (psoc creator 3.0) without purchasing a board to check out its capabilities.

Corla Plankun
May 8, 2007

improve the lives of everyone

echinopsis posted:

yeah it was

but the duty cycle was based off a sine wave


oh yeah... ill need to LOOKUP how to make one

its not like a complicated programming thing or anything, you just manually copy-paste the values into a vector and then use the vector instead of using a function

echinopsis
Apr 13, 2004

by Fluffdaddy
wow u guys talk about this like its grade school poo poo

I gotta do me some learning

echinopsis
Apr 13, 2004

by Fluffdaddy
yeah my thing is that every new thing I code I have to go learn how to code it not just apply the concept to coding which I already understand. I know what a lookup table means but implementing one means learning [again] how to use an array

shits simple in python but C makes you jump through hoops for everything

still it's a good challenge. peace

maybe I could use the Internet and wolfram alpha to get values?

Bloody
Mar 3, 2013

Stealth Like posted:

posted about it before but anyone wanting to do things more complicated than blinking LEDs or w/e should look in to these http://www.cypress.com/?rID=78840&source=psoc

a bit pricier than an arduino but leagues more functional. build in adc (12 and 20 bit), current and voltage dacs, op amps, counters, usb support, spi, i2c, serial, etc. components are added with an easy to use schematic format where you drag and drop them on to it. then you can code the functionality in C++, using their free IDE. the libraries for things like spi etc are included in the ide so you dont need to mess with them.

you can pick up a full pinout one here for $75 http://freesoc.myshopify.com/products/freesoc-development-kit

there's tons of examples in the ide, and each component has a pdf of the datasheet for that component with information on how it functions, as well as the API for it.

you can download the ide (psoc creator 3.0) without purchasing a board to check out its capabilities.

cypress pee socks

Bloody
Mar 3, 2013

echinopsis posted:

yeah my thing is that every new thing I code I have to go learn how to code it not just apply the concept to coding which I already understand. I know what a lookup table means but implementing one means learning [again] how to use an array

shits simple in python but C makes you jump through hoops for everything

still it's a good challenge. peace

maybe I could use the Internet and wolfram alpha to get values?

unsigned char sin_lut[] = { 128,131,134,137,140,143,146,149,152,155,158,162,165,167,170,173,176,179,182,185,188,
190,193,196,198,201,203,206,208,211,213,215,218,220,222,224,226,228,230,232,234,235,
237,238,240,241,243,244,245,246,248,249,250,250,251,252,253,253,254,254,254,255,255,
255,255,255,255,255,254,254,254,253,253,252,251,250,250,249,248,246,245,244,243,241,
240,238,237,235,234,232,230,228,226,224,222,220,218,215,213,211,208,206,203,201,198,
196,193,190,188,185,182,179,176,173,170,167,165,162,158,155,152,149,146,143,140,137,
134,131,128,124,121,118,115,112,109,106,103,100,97,93,90,88,85,82,79,76,73,70,67,65,
62,59,57,54,52,49,47,44,42,40,37,35,33,31,29,27,25,23,21,20,18,17,15,14,12,11,10,9,7,
6,5,5,4,3,2,2,1,1,1,0,0,0,0,0,0,0,1,1,1,2,2,3,4,5,5,6,7,9,10,11,12,14,15,17,18,20,21,
23,25,27,29,31,33,35,37,40,42,44,47,49,52,54,57,59,62,65,67,70,73,76,79,82,85,88,90,
93,97,100,103,106,109,112,115,118,121,124}; here u go, this is my preferred flavor of sin lookup table. it's a full cycle of a wave centered at 127, 256 elements long so u can fart out a sine wave like:

char i = 0;
while(true)
{
dac_or_whatever = sin_lut[i++];
}

Luigi Thirty
Apr 30, 2006

Emergency confection port.

I like my Arduino because atmel studio is a custom version of visual studio and visual studio is the best IDE ever made

Bloody
Mar 3, 2013

same except why i love every atmel product

echinopsis
Apr 13, 2004

by Fluffdaddy
bloody that looks great. and easy. would u use a % so u didn't worry about out of bounda? also awful not letting me quote sorry. Thabks

Arcsech
Aug 5, 2008

Stealth Like posted:

posted about it before but anyone wanting to do things more complicated than blinking LEDs or w/e should look in to these http://www.cypress.com/?rID=78840&source=psoc

a bit pricier than an arduino but leagues more functional. build in adc (12 and 20 bit), current and voltage dacs, op amps, counters, usb support, spi, i2c, serial, etc. components are added with an easy to use schematic format where you drag and drop them on to it. then you can code the functionality in C++, using their free IDE. the libraries for things like spi etc are included in the ide so you dont need to mess with them.

you can pick up a full pinout one here for $75 http://freesoc.myshopify.com/products/freesoc-development-kit

there's tons of examples in the ide, and each component has a pdf of the datasheet for that component with information on how it functions, as well as the API for it.

you can download the ide (psoc creator 3.0) without purchasing a board to check out its capabilities.

paging Otto Skorzeny to this thread

do not use cypress psocs

echinopsis posted:

bloody that looks great. and easy. would u use a % so u didn't worry about out of bounda? also awful not letting me quote sorry. Thabks

nope if i is an unsigned char (uint8_t) it will automatically overflow back to zero after 255

Bloody
Mar 3, 2013

Arcsech posted:

nope if i is an unsigned char (uint8_t) it will automatically overflow back to zero after 255

this is the beauty, this way if you're pumping it into a dac or w/e all your samples come out evenly spaced with no effort n poo poo

Sagebrush
Feb 26, 2012

the arduino (c) trig libraries literally do just load a LUT i think, with all the program space requirements and access times that implies

Bloody posted:

if u want sin() the function then make a 360-element lut

yeah

Captain Cool posted:

don't do trig on a microprocessor, it's horribly expensive (ms of time if you're lucky and kb of library code)

you should be able to walk along parabolas and get plenty close for visual effect

brightness = 50%
slope = 10
loop:
brightness > 50%? slope-- : slope++
brightness += slope
wait

might want to reset parameters at the 50% crossing to keep errors from accumulating but that's the idea

in my experience doing trig isn't "milliseconds" of time, but i was curious to know just how much longer it takes, so i tested it

a is float, the others are ints, ran on a 16mhz atmega328 (i.e. an arduino)

code:
  start = micros();
  brightness = sin(a*PI/180)*127;
  a++;
  finish = micros();
  Serial.print(finish-start);
time: 168+/-4 microseconds
size: 4012b (note, some of this is the floating point lib)

code:
  start = micros();
  brightness > 127 ? slope-- : slope++;
  brightness += slope;
  finish = micros();
  Serial.print(finish-start);
time: 8+/-4 microseconds
size: 2712b

lollin'

pretty nice output too, that's definitely close enough to a sine for led fading


yeah i did once write myself a little graphing app to look at serial data and i gave it yospos colors. wanna fight about it

Sagebrush fucked around with this message at 00:16 on Jul 4, 2014

Sagebrush
Feb 26, 2012

Bloody posted:

here u go, this is my preferred flavor of sin lookup table.

we have a winner!

code:
  start = micros();
  brightness = (sin_lut[i++]);
  finish = micros();
  Serial.print(finish-start);
time: 8+/-4us
size: 2616b

and it's a true sine wave too

zeekner
Jul 14, 2007

Sagebrush posted:

we have a winner!

code:
  start = micros();
  brightness = (sin_lut[i++]);
  finish = micros();
  Serial.print(finish-start);
time: 8+/-4us
size: 2616b

and it's a true sine wave too

how much slower is it if you stuff that array in PROGMEM?

Sagebrush
Feb 26, 2012

Stealth Like posted:

posted about it before but anyone wanting to do things more complicated than blinking LEDs or w/e should look in to these http://www.cypress.com/?rID=78840&source=psoc

a bit pricier than an arduino but leagues more functional. build in adc (12 and 20 bit), current and voltage dacs, op amps, counters, usb support, spi, i2c, serial, etc.

every atmega and attiny has 1-16 adc channels (10 bit yes), counters, spi, i2c and serial. a lot of the megas have usb support. dacs and op-amps are a little harder to find.

the avr series is good for a hell of a lot more than just blinking leds and that's kind of the point. i've seen live fourier transforms being done on an 8mhz atmega while running pwm on several channels and keeping up various little side tasks (reading buttons, etc). psocs and arms and stuff are great but a single $3 mega can do a hell of a lot more than people give them credit for

echinopsis posted:

shits simple in python but C makes you jump through hoops for everything

this is why python is a garbage first language to learn. bad habits. C is how computers REALLY work. (yes i imagine someone was saying this ca. 1980 about assembly)

Captain Cool
Oct 23, 2004

This is a song about messin' with people who've been messin' with you

Sagebrush posted:

the arduino (c) trig libraries literally do just load a LUT i think, with all the program space requirements and access times that implies
neat, this makes sense

quote:

in my experience doing trig isn't "milliseconds" of time,
maybe that was trig + floats, one microprocessor library I almost worked with used coordinate rotation and arithmetic series until convergence or something

also one of the first programs I worked on at this company had some half-second delays while spewing out data. I looked at the code and found all of that delay was in "pow(2,x)". this was a DOS program that ran on a desktop CPU

Luigi Thirty
Apr 30, 2006

Emergency confection port.

i have a b&k 60mhz oscilloscope I paid 10 dollars for the college was selling how do I draw a dick on it with my Arduino

Sagebrush
Feb 26, 2012

Uncomfortable Gaze posted:

how much slower is it if you stuff that array in PROGMEM?

ooh good point. i knew there was something that bugged me about that method. yeah it wins for speed but that single table eats up 1/8 of the chip's total ram. ouch

after sticking the array in progmem:
code:
  start = micros();
  brightness = (pgm_read_byte_near(sin_lut + (i++)));
  finish = micros();
  Serial.print(finish-start);
time: 8+/-4us
size: 2808b

forums poster "uncomfortable gaze" is the new winner because the code is the same speed (within timer accuracy) but using 200B of program space is better than using 2Kbit of RAM!

e: 2Kbit. drat that's a fat rear end table

Sagebrush fucked around with this message at 00:52 on Jul 4, 2014

zeekner
Jul 14, 2007

sweet. i keep running into memory limits on a project, progmem would be nice but this is all buffered serial data so i can't use it. 2k is not much to work with :/

Luigi Thirty
Apr 30, 2006

Emergency confection port.

well supposedly we're going to have multimillion bit memory devices by 1989

echinopsis
Apr 13, 2004

by Fluffdaddy
how do u utilise progmem. it's way beyond me just curious

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp
cistps: put in the 12v feed for the network closet in the hallway



NAS, router, AP, switch all run straight off of 12v.

EMILY BLUNTS
Jan 1, 2005

what would you do for power filtering, if anything, for DC devices all hooked up to a bus (on a bus)

Sagebrush
Feb 26, 2012

u include the library:

code:
#include <avr/pgmspace.h>
then you define the variables you want to store as being placed in PROGMEM:

code:
PROGMEM int8_t farts_count[] = {2, 5, 20, 94, 2, 97, 5};
(i am using the signed 8-bit int type here, this is the same as saying "char" on arduino)

and then you need the special access method to get them back out

code:
todays_farts = (pgm_read_byte_near(farts_count + 3));
//i farted 94 times today
(where 3 is the index of the array, but you're not really reading it that way, you're just stepping through the memory in sequence since that's how the array is stored)

it is like using an array, but not.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

there are progmem versions of the C string functions as well which you would need to use if you put them in progmem

Adbot
ADBOT LOVES YOU

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp

EMILY BLUNTS posted:

what would you do for power filtering, if anything, for DC devices all hooked up to a bus (on a bus)

well, this is on the coach (not the starter motor) battery system. it is always connected to 440 AH of deep cycle batteries, which are pretty good at eating most spikes. The house charger is a brand new modern switching unit that puts out 60 amps of clean, regulated DC. The only time this sees alternator is when I flip the switch driving to charge the coach batteries off of the chassis system. and that will only be in motion, when everything's turned off

if i wanted to do something though i'd probably do a multi tier system of ~20V zener for overvolt crowbar action and a big rear end hand wound choke on a head bolt or something, L-networked with as much cap as I could find.

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