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 $3,400 per month for bandwidth bills alone, and since we don't believe in shoving popup ads to our registered users, we try to make the money back through forum registrations.
«531 »
  • Post
  • Reply
Josh Wow
Feb 28, 2005

We need more beer up here!


No trade secrets, it's beer. Right now I have it set up with the air nozzle always blowing, but have quality concerns about blowing air into the can. No other gas would be cheap enough to use for this, hence why I'm trying to set it up to only trigger for a specific can. If I can get that set up I could also just use CO2 since it would be running very infrequently and eliminate all quality concerns.

I know what sensors I need to use and how I would set them up but for example don't know how to power them or get the signal from the two sensors to trigger the relay. I've googled around for this but can"t seem to find a good resource to teach me these things. Appreciate all the responses.

Adbot
ADBOT LOVES YOU

Sagebrush
Feb 26, 2012





Gravy Boat 2k

The screen door blows open and the wind whispers "....aaaaaarrrduiiiiiiiinoooooo..."

Shame Boy
Mar 2, 2010

THE HORROR
THE HORROR





Is this the kind of industrial thing where failing to do its job or being down for any amount of time for repair will cost millions of dollars or w/e because I'd think that will significantly change the answers

Sagebrush
Feb 26, 2012





Gravy Boat 2k

If this is the kind of industrial thing where failing to do its job or being down for any amount of time for repair will cost millions of dollars I think the poster should not be asking how to roll a system themselves on The Something Is Awful discussion forums. Certainly not if their questions start with "how do I power this sensor." Hire an engineer.

q.v. that guy who wanted to build a 5000 watt LED array for a dance floor

Stack Machine
Mar 6, 2016

I can see through time!


Fun Shoe

I was thinking of blowing air over sealed cans. I can see how you wouldn't just want to crank whatever's floating around the room right into totally open beer cans. I really like density/weight-based solutions for this because they're robust to room lighting changes etc. But for your actual question I second Arduino. I think most of them give you 3.3V and 5V from a USB supply. I assume you don't need guaranteed PPM failure rates or anything because this is presumably a pilot project and qualification etc comes later, but no matter what you set up don't expect low error rates off the bat unless somebody sold the solution to you and guaranteed that in writing.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell



I asked about this in the wiring thread, but I'll ask here as well.

How do I measure power consumption of a 220v appliance to get it's cost to run?

I'm wanting to figure out exactly how much a heat pump water heater is saving me, so I have my old resistance water heater hooked up and valved so I can switch between it and the new heat pump unit.

I can obviously clamp a CT over each leg, but I'm not sure if I should be adding those values or taking the highest value or what. I'm sure it's a complex load that's running 110v for some stuff and 220v for some other stuff. There's fans and compressors and electronics and resistive heaters all inside this thing.

Stack Machine
Mar 6, 2016

I can see through time!


Fun Shoe

I assume you're in the US so this is an appliance with a 4-prong L1/L2/N/G outlet. The total power is the sum of the currents in the 2 hot wires times 120V. There's probably not much flowing through the neutral so you could likely cheap out and measure one leg and multiply the current by 240 but the two leg method will work no matter what the load looks like.

Foxfire_
Nov 8, 2010



For a water heater, the vast majority of the power consumption will be resistive and you don't really need anything more than

Power = V_rms * I_rms

So measure average current going in with your current transducer clamped over one lead, assume that the voltage is 220Vrms (or measure it very carefully), then multiply to get the power dissipated. This won't tell you how much of that power goes into the water, but that would require knowing a lot of efficiency information specific to the water heater design.

Doing an actual cost comparison between the two will require stuff beyond straight electrical power usage and won't be a simple number. Imagine if you had two heaters where one had more efficient heating and one had better insulation. Cost comparison will give you different answers for which is better depending on how much you are heating up new cold water vs maintaining temp on previously heated water.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell



Stack Machine posted:

I assume you're in the US so this is an appliance with a 4-prong L1/L2/N/G outlet. The total power is the sum of the currents in the 2 hot wires times 120V. There's probably not much flowing through the neutral so you could likely cheap out and measure one leg and multiply the current by 240 but the two leg method will work no matter what the load looks like.

It's L1/L2/G. This is how every water heater I've seen around here (Missouri) is wired.


Foxfire_ posted:

For a water heater, the vast majority of the power consumption will be resistive and you don't really need anything more than

Note that the new water heater is a heat pump water heater and depending on the mode its running in it will use no resistive heating.

Foxfire_ posted:

Doing an actual cost comparison between the two will require stuff beyond straight electrical power usage and won't be a simple number. Imagine if you had two heaters where one had more efficient heating and one had better insulation. Cost comparison will give you different answers for which is better depending on how much you are heating up new cold water vs maintaining temp on previously heated water.


I'm looking at understanding the system as a whole. If I run one of them for a month and measure it's power consumption over that time and then do the same with the other...that should tell me how much it costs to run each of them no?

Stack Machine
Mar 6, 2016

I can see through time!


Fun Shoe

If you are sure the third wire is a ground and not a neutral and the appliance is functioning correctly there is guaranteed to be 0 current flowing in the ground, so the currents in the two hot legs will be equal and you can just use a single current transformer on either hot wire and multiply that by 240 (less accurate) or the measured voltage (more accurate) to get your power usage.

Even if it were a thing with L1/L2/N, the 120V paths are almost always very lightly loaded, e.g. only used for powering control electronics.

sharkytm
Oct 9, 2003

Gimme Gimme Swedish Fish...

Fallen Rib

Josh Wow posted:

No trade secrets, it's beer. Right now I have it set up with the air nozzle always blowing, but have quality concerns about blowing air into the can. No other gas would be cheap enough to use for this, hence why I'm trying to set it up to only trigger for a specific can. If I can get that set up I could also just use CO2 since it would be running very infrequently and eliminate all quality concerns.

I know what sensors I need to use and how I would set them up but for example don't know how to power them or get the signal from the two sensors to trigger the relay. I've googled around for this but can"t seem to find a good resource to teach me these things. Appreciate all the responses.

CO2 probably isn't a great idea either unless you've got air monitoring sensors. Your $4 micro got hung up and just opened the air solenoid for two hours, now you've got no air to breathe.

Serious answer: PLC and industrial controls/sensors. And also talk to your manufacturing engineer, this is what they get paid to build.

um excuse me
Jan 1, 2016

This avatar brought to you by the 'save our dead gay forums' foundation.


A CO2 displaced environment is definitely noticable and not pleasant to be in like a CO one. Your body actually has a triggered response to CO2 of the "OH GOD I CANT BREATHE" variety.

taqueso
Mar 8, 2004









Fun Shoe

Some kind of mini PLC is probably what you want, lots of things about like the photo below that have varying levels of expandability and programmability and cost < $500

This particular one I just grabbed because its a good example of the form factor I know nothing about it


You could also do it with arduino (or similar) stuff but one of these will already be industrial and have features like IO that won't blow up when you breath on them wrong. Usually these come with graphical programming systems, which might be a plus.

taqueso fucked around with this message at 02:39 on May 22, 2020

sharkytm
Oct 9, 2003

Gimme Gimme Swedish Fish...

Fallen Rib

um excuse me posted:

A CO2 displaced environment is definitely noticable and not pleasant to be in like a CO one. Your body actually has a triggered response to CO2 of the "OH GOD I CANT BREATHE" variety.

Oh I know, but lack of oxygen takes no prisoners. Maybe it's hyperbole, but my point still stands. PLCs exist for a reason in industry.

Some Goon
Jan 6, 2013
Probation
Can't post for 3 days!


I need a handful of tactile switches for some coronaprojecting, but it turns out shipping 20 switches costs as much as or more than the switches themselves (sad, but not really surprising). As I have to imagine I'm well below whatever minimum weight / volume would increase shipping costs, are there any miscellaneous components that would typically be useful to have on hand for future yet unknown projects, so I can actually get my money's worth out of the shipping costs?

Alternatively, is there anywhere better than Digikey / Mouser for buying small numbers of very specifically sized components?

Forseti
May 26, 2001
To the lovenasium!


Voltage regulators are pretty useful to have on hand. Something like 10x LM317s?

Get some heatsinks too if you think you'll drop the input voltage by a largish amount/get near its current limit.

ante
Apr 9, 2005

No... Not without incident.

For switches, instead of buying 20 + shipping from Digikey, it's often worth it to buy 1000 + express shipping from AliExpress

Piss Meridian
Mar 25, 2020


Use a Micrologix plc or similar. AutomationDirect have some interesting units that I have never used

ante posted:

For switches, instead of buying 20 + shipping from Digikey, it's often worth it to buy 1000 + express shipping from AliExpress

Sure, as long as you have no expectation of lifespan or reliability (or fire safety)

Piss Meridian fucked around with this message at 03:58 on May 22, 2020

taqueso
Mar 8, 2004









Fun Shoe

Piss Meridian posted:

Sure, as long as you have no expectation of lifespan or reliability (or fire safety)
that was my thought

ante
Apr 9, 2005

No... Not without incident.

if dude is having issues trying to toggle a pin, don't tell him to get a PLC lol


There's no magic that makes them only operate safely, you still need to know how to do it.

Just use plain air and an Arduino

sharkytm
Oct 9, 2003

Gimme Gimme Swedish Fish...

Fallen Rib

Forseti posted:

Voltage regulators are pretty useful to have on hand. Something like 10x LM317s?

Get some heatsinks too if you think you'll drop the input voltage by a largish amount/get near its current limit.

Another good buy are the switching "317 replacements" that don't turn half your power into heat, if you don't care about noise. Or do what I've done in the past, and use a switcher to drop most of the voltage, then a linear to get a nice supply voltage.

taqueso
Mar 8, 2004









Fun Shoe

ante posted:

if dude is having issues trying to toggle a pin, don't tell him to get a PLC lol


There's no magic that makes them only operate safely, you still need to know how to do it.

Just use plain air and an Arduino

i mean, those little PLCs come with graphical software that lets you set a pin, and probably watch sensor status over usb or a network

of course they only do what you tell them, but they are much much harder to crash

Shame Boy
Mar 2, 2010

THE HORROR
THE HORROR





taqueso posted:

i mean, those little PLCs come with graphical software that lets you set a pin, and probably watch sensor status over usb or a network

of course they only do what you tell them, but they are much much harder to crash

They also come with UL listing and warranties and poo poo that I'd imagine your insurance company would very much like to know about if something fails and catches fire.

sharkytm
Oct 9, 2003

Gimme Gimme Swedish Fish...

Fallen Rib

Shame Boy posted:

They also come with UL listing and warranties and poo poo that I'd imagine your insurance company would very much like to know about if something fails and catches fire.

A thousand times this... In a commercial operation where you have employees (OSHA) and the ramifications are either deadly/dangerous or expensive, you have to go with industrial parts. That means UL/CSA, bought from a licensed reseller to ensure authenticity of the parts,, and installed 100% to code, preferably by a licensed electrician/installer. If you're a person in your basement bottling beer, feel free to Arduino the gently caress out of this project.

Another recent example: the person who wanted to automate their chicken coop with a solar panel and some sensors. Perfect diy project, especially with a detached coop. If something fails and the coop burns, it's a couple dead chickens and an outbuilding up in smoke. In a commercial farm, you're talking about thousands of dead birds, possibly dead employees, millions in losses due to defaulted contracts and loss of revenue, and likely OSHA fines.

Stack Machine
Mar 6, 2016

I can see through time!


Fun Shoe

Speaking of PLCs, an interesting tidbit of electrical knowledge is the 4-20mA current loop used by industrial sensors. It's a 2-wire interface where the sensor controls the current in the wire and the PLC or other controller just regulates the voltage and reads the current. It's a damned elegant interface for its intended application:

It's easy to detect open/short circuit faults because they place the current outside the valid range.

Dirty contacts? Extra resistance in the circuit? Very long runs of cable to your sensor? No problem!

Need to power your sensor? Is 4mA enough? There are regulators just for that.

Faults won't start a fire readily unless the supply voltage limit is super high. 20mA at 12V is less than a quarter watt.

Parasitic inductance and capacitance will affect how fast the current can change but they won't affect the ability of the circuit to operate. This is something wired digital interfaces can't do.

If you do go the PLC route and get some "loop-powered" sensors, you'll only have 2 wires to connect for each sensor, which will both power them and carry the signal.

silence_kit
Jul 14, 2011


Stack Machine posted:

Parasitic inductance and capacitance will affect how fast the current can change but they won't affect the ability of the circuit to operate. This is something wired digital interfaces can't do.

? What do you mean here?

TacoHavoc
Dec 31, 2007
It's taco-y and havoc-y...at the same time!

silence_kit posted:

? What do you mean here?

A digital interface operates by changing the voltage level on a wire from one voltage to another rapidly. Wire resistance and capacitance increase as wires get longer, meaning the wire gets less ideal and square waveforms start to get less and less square. The additional capacitance slows edge rates, which in a digital circuit means eventually your communication bus will fail due to missing signal timing windows. In 4-20 mA, the slightly slowed circuit response won't affect the end device.

The obvious tradeoff is amount of data sent. 4-20 basically sends one "command", which is a current level equivalent to a position. On a digital bus you have much more flexibility.

silence_kit
Jul 14, 2011


TacoHavoc posted:

A digital interface operates by changing the voltage level on a wire from one voltage to another rapidly. Wire resistance and capacitance increase as wires get longer, meaning the wire gets less ideal and square waveforms start to get less and less square. The additional capacitance slows edge rates, which in a digital circuit means eventually your communication bus will fail due to missing signal timing windows. In 4-20 mA, the slightly slowed circuit response won't affect the end device.

The obvious tradeoff is amount of data sent. 4-20 basically sends one "command", which is a current level equivalent to a position. On a digital bus you have much more flexibility.

Ok, that is what he means. I understand that wiring can affect max signal speed. Don't forget about inductance. Sometimes you have to worry about the inductance of wires as well.

Don't many digital interfaces have adjustable clock speeds/data rates though?

silence_kit fucked around with this message at 15:40 on May 22, 2020

mobby_6kl
Aug 9, 2009

"You are the best poster... do not let anyone say otherwise."


I've been trying to get ADC working on an ESP32 using the I2S with the internal ADC as shown in this example: https://github.com/espressif/esp-id...als/i2s_adc_dac

I was feeding the signal into FFT and it was difficult to figure out what was the problem until I realized this is the moment my multimeter's square wave generator has been waiting for (used a diode here as it's generating 5v P2P). As you can see, it "works" but starts to really fall apart after 1kHz.



Just using AnalogRead in a loop works better for higher frequencies


But changing APLL in the I2S settings seem to get similar results.


Still this all seems pretty bad to me. Any ideas what could be going wrong here? The ESP ADC isn't great but it should be good enough for 10kHz at least, they have examples sampling at 70kHz.
code:
#define NUM_SAMPLES   512
#define I2S_NUM         (0)

void configure_i2s() {
	i2s_config_t i2s_config =
	{
	.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_ADC_BUILT_IN),  // I2S receive mode with ADC
	.sample_rate = 22000,                                           
	.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,                                 
	.channel_format = I2S_CHANNEL_FMT_ALL_LEFT,                                  
	.communication_format = I2S_COMM_FORMAT_I2S_MSB,// (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB),   // I2S format
	.intr_alloc_flags = 1,                                                        // none
	.dma_buf_count = 2,                                                           
	.dma_buf_len = NUM_SAMPLES,                                                  
	.use_apll = 0,                                                                // 1 seems to be better for lower frequency signals
	};
	adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_11db);
	adc1_config_width(ADC_WIDTH_12Bit);
	i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
	 
	i2s_set_adc_mode(ADC_UNIT_1, ADC1_CHANNEL_0);
	SET_PERI_REG_MASK(SYSCON_SARADC_CTRL2_REG, SYSCON_SARADC_SAR1_INV); //invert the adc back to normal
	i2s_adc_enable(I2S_NUM_0);
}

uint16_t i2s_read_buff[NUM_SAMPLES];
SemaphoreHandle_t i2s_sem = NULL;


void adc_read_task(void *parm) {
	while (1) {
		//xSemaphoreTake(i2s_sem, portMAX_DELAY);
		i2s_read_bytes(I2S_NUM_0, i2s_read_buff, NUM_SAMPLES * sizeof(uint16_t), portMAX_DELAY);
		//xSemaphoreGive(i2s_sem);
	}
}

void loop() {
	//xSemaphoreTake(i2s_sem, 1);
	for (int i = 0; i < NUM_SAMPLES; i++) {
		Real[i] = i2s_read_buff[i];
		//Serial.println(i2s_read_buff[i]);
	}
	//xSemaphoreGive(i2s_sem);
}


void setup() {
	configure_i2s();

	vSemaphoreCreateBinary(i2s_sem);
	xSemaphoreGive(i2s_sem);
	xTaskCreate(adc_read_task, "ADC read task", 2048, NULL, 5, NULL);
	Serial.println("Finished setup");
}
BTW, should I be using a mutex or semaphore there to prevent reading from the buffer while it's being used? it doesn't seem to make a difference in testing.


Also also, completely unrelated: is it possible to have PCBs of irregular shapes made? I have an idea that would require a roughly banana-shaped board (flat, obviously).

Stack Machine
Mar 6, 2016

I can see through time!


Fun Shoe

silence_kit posted:

Ok, that is what he means. I understand that wiring can affect max signal speed. Don't forget about inductance. Sometimes you have to worry about the inductance of wires as well.

Don't many digital interfaces have adjustable clock speeds/data rates though?

The wire to the device is a distributed inductance and capacitance. The magic words to learn about this are "transmission line theory", but what it means practically is that there is a limit to transmission speed for non-terminated lines of a given length. Terminations give you fast digital at multiple wavelengths of length but burn power and limit cable length for a given wire diameter by forming a resistive voltage divider with the cable resistance itself.

Something like modbus gives you a configurable bit rate and terminated connections so you can transmit fast over a long distance. It's super attractive for a lot of applications. More than one sensor per bus, perfectly accurate data transmission with CRC. It's robust but complex. Current loop is robust but simple and perhaps a bit counterintuitive as a choice since few analog signals are represented as currents for transmission. I mentioned it here because its design solves common electrical problems very well with the application of very basic electrical principles, which seems like it may be of interest to people learning electronics.

shovelbum
Oct 21, 2010



Fallen Rib

mobby_6kl posted:

Also also, completely unrelated: is it possible to have PCBs of irregular shapes made? I have an idea that would require a roughly banana-shaped board (flat, obviously).

Yeah it still gets punched out of a rectangle so there are cost concerns until you get into having a full sheet made and can nest them efficiently but what you do is you slot out the shape of the board from your rectangle size, but leave it partly connected with mouse bites. The last time I did a board with mouse bites on one of the cheap services I noticed that they just put down their own mouse bite shape instead of exactly mine, like they know what you're going for you know?

Stack Machine
Mar 6, 2016

I can see through time!


Fun Shoe

mobby_6kl posted:

Still this all seems pretty bad to me. Any ideas what could be going wrong here? The ESP ADC isn't great but it should be good enough for 10kHz at least, they have examples sampling at 70kHz.

I think your parallel tasks are not running in parallel. I think you're getting bursts of samples at your set rate followed by your micro switching to its main loop task. Try something simple. Just read a thousand or so samples into a buffer without a separate task then output them. Can you operate at higher speeds then?

taqueso
Mar 8, 2004









Fun Shoe

mobby_6kl posted:

Also also, completely unrelated: is it possible to have PCBs of irregular shapes made? I have an idea that would require a roughly banana-shaped board (flat, obviously).

You can do whatever you want, essentially. These days at almost no additional cost, once upon a time there would be tooling fees for anything that wasn't a drill or rectangle.

Forseti
May 26, 2001
To the lovenasium!


TacoHavoc posted:

A digital interface operates by changing the voltage level on a wire from one voltage to another rapidly. Wire resistance and capacitance increase as wires get longer, meaning the wire gets less ideal and square waveforms start to get less and less square. The additional capacitance slows edge rates, which in a digital circuit means eventually your communication bus will fail due to missing signal timing windows. In 4-20 mA, the slightly slowed circuit response won't affect the end device.

The obvious tradeoff is amount of data sent. 4-20 basically sends one "command", which is a current level equivalent to a position. On a digital bus you have much more flexibility.

Genuine question, what about a signal like phase-shift keying? The information is ultimately digital information but is encoded by changing the phase of the modulating sine and cosine. Is the actual interface therefore considered not a digital interface?

Also, the 4-20mA interface is a form of differential signaling? Just purely analog instead of something like LVDS used for many of the modern digital serial buses?

TotalLossBrain
Oct 20, 2010

Hier graben!

Forseti posted:

Also, the 4-20mA interface is a form of differential signaling? Just purely analog instead of something like LVDS used for many of the modern digital serial buses?


It just maps the range of the process variable (whatever the transmitter is measuring) to the range of the 4-20 mA signal. I'd call it a scaled analog before differential, no?

Forseti
May 26, 2001
To the lovenasium!


I see, I guess I got hung up on the 2-wire aspect of it. I'm not an EE myself just always eager in learning more so I'll probably use terminology wrong or imprecisely too.

Stack Machine
Mar 6, 2016

I can see through time!


Fun Shoe

Differential signaling uses the difference between voltages on two wires. It's really good at rejecting common-mode noise (noise in both conductors relative to ground). Current loop is a current mode thing. The voltages in the wires are not relevant to the data being transmitted so what they do relative to ground is not really relevant either. There just has to be enough voltage between them to handle the drop at the sensor.

Re phase shift keying, modulation doesn't shrink the bandwidth of your signal. It just moves it around the spectrum. If the problem is that the high frequency content of your signal is getting lost, moving to a higher frequency will likely not help. Moving to a controlled transmission line like twisted pair and using a terminating resistor, however, will help.

Forseti
May 26, 2001
To the lovenasium!


So sort of analogous to how an incandescent light bulb is a "voltage device" and an LED is a "current device"? Which I understand as meaning if you put a fixed voltage across a light bulb it will limit the current based on its resistance (which I know is not fixed but rather conveniently limited by heating up and reaching a balance before destruction) but an LED wants a current regulated power source and will have a voltage drop that depends on the specifics of its junction.

Sagebrush
Feb 26, 2012





Gravy Boat 2k

Both a light bulb and an LED are current devices in that their light output depends on the current flow. A light bulb is just an ohmic device, meaning that its resistance increases with current and thus it self-stabilizes, while an LED is not -- it has a constant fixed drop and any voltage beyond that will see a dead short. You can abstract this as a voltage control of brightness for the light bulb, since you don't need to control the current directly, but that's definitely a simplification.

Adbot
ADBOT LOVES YOU

Shame Boy
Mar 2, 2010

THE HORROR
THE HORROR





Forseti posted:

So sort of analogous to how an incandescent light bulb is a "voltage device" and an LED is a "current device"? Which I understand as meaning if you put a fixed voltage across a light bulb it will limit the current based on its resistance (which I know is not fixed but rather conveniently limited by heating up and reaching a balance before destruction) but an LED wants a current regulated power source and will have a voltage drop that depends on the specifics of its junction.

It's a little weird to describe a light bulb as a "voltage device", it's just entirely resistive (as in it obeys ohm's law) while an LED does not. I mean I guess it makes sense what you're saying, but when I hear "voltage device" I think MOSFET, a transistor that is controlled entirely by voltage with (ideally) no current flow through the gate, versus a "current device" BJT that's controlled entirely by current through the base with (ideally) the voltage not mattering.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply
«531 »