Multiple thermocouples on raspberry pi - NAN reading when in electrical contact - raspberry-pi3

I have 2 K-type thermocouples running on individual MAX31855 boards on a Raspberry Pi 3.
The MAX31855 boards share a CLK pin but have separate CS and DO pins, similar to the set up given here:
Multiple thermocouples on raspberry pi
Everything works great until i place both thermocouples on a metal surface which causes both thermocouple readings to be "NAN". I guess its a grounding issue? Is there a way to solve this?
Thanks in advance

You can glue them with epoxy to the devices you are monitoring. Thermo-couples should not be connected together electrically and it sounds as though you may have grounded them. Also, I don't know how the MAX works precisely, but in order to be able to read negative temperatures, the thermo-couples are probably biased UP slightly (maybe 10mV).
If you ground them this means they will read a voltage that translates as -10mV which would be a temperature lower than absolute zero. Hence, NaN, i.e. not a number.
I do know how the TH7 works and the python code for driving that (its a raspberry pi thing) is here https://github.com/robin48gx/TH7

Related

FPGA LUT with multiple outputs

I am working on designing a mandelbrot viewer and I am designing hardware for squaring values. My squarer is recursively built where a 4bit squarer relies on 2, 2bit squarers. so for my 16 bit squarer, that has 2 8bits squarers, and each one of those has 2 4bit squarer's.
As you can see the recursivity begins to make the design blow up in complexity. To help speed up my design i would like to use a 4input ROM that emulates a 4bit squarer. So when you enter 3 in the rom, it outputs 9, when you enter 15, it outputs 225.
I know that a normal LUT implemented in a logic cell ay have 3 or 4 input variables and only 1 output, but i need an 8 bit output so I need more of a ROM then a LUT.
Any and all help is appreciated, Im curious how the FPGA will store those ROMs and if storing it in ROM would be faster than computing the 4input Square.
-
Jarvi
To square a 4-bit number explicitly using LUTs, you would need to use 8 4-input LUTs. Each LUT's output would give you one bit of the 8-bit product.
The overall size and fmax performance of your design may be achieved with this approach, using larger block RAM primitives (as ROM), dedicated MAC (multiply-accumulate) units, or by using the normal mulitiplication operator * and relying on your synthesis tool's optimization.
You may also want to review some research papers related to this topic, for example here.

How do I make two servo's move in opposite directions?

I am trying to make a model of the muscle system in the arm for a project with Arduino, but to accomplish this I need bicep and triceps to move in opposite direction.
I am currently experimenting with a potentiometer and trying to make the two servos move in opposite directions, but somehow the code doesn't seem to work as I would expect since they keep moving in the same direction.
My power supply is my laptop, I haven't used a battery pack yet. As for the specific issue, the servos aren't responding to the potentiometer and they just jitter
#include <Servo.h>
Servo Bicep;
Servo Tricep;
Servo Extensor;
Servo Flexor;
int pos = 0;
int biceppin = 3;
const int triceppin = 4;
const int extensorpin = 5;
const int flexorpin = 6;
int potpin = 8;
int potval = 0;
int potval2;
void setup() {
Bicep.attach(biceppin);
Tricep.attach(triceppin);
Extensor.attach(extensorpin);
Flexor.attach(flexorpin);
}
void loop() {
potval = analogRead(potpin);
potval = map(potval, 0, 1023, 0, 180);
potval2 = 180 - potval;
Bicep.write(potval);
Tricep.write(potval2);
delay(15);
}
Would you be able to tell me what is wrong with the code?
Is there a more efficient way to do the same task?
You set potpin = 8, but analogRead() works only over analog inputs A0-A5 and on most boards, included the tagged Arduino Uno board, pin 8 is a digital pin.
relevant quote:
[...] you cannot use analogRead() to read a digital pin. A digital pin cannot behave as analog because it isn't connected to the ADC (Analog to Digital Converter).
You can test this with the example of https://www.arduino.cc/en/Reference/AnalogRead
I think that there are more than one problem there.
Assuming the program is correct (which may not be the case, since as explained in #BOC's answer you are using pin 8 as an analog input while in an Arduino Uno board, that pin is only digital), if the servos jitter, a good candidate as the source of the problem is your power supply:
You stated (on a comment, but I edited your question to specify this, since it's important) that your power supply is your laptop. Most USB ports are limited to 500 mA.
Although you did not explain anything about your particular servos and their specifications, most of them use at least 250 mA (for example, a Futaba S3003). But low cost/low quality servos usually take more than that, as well as bigger servos. But even if your servos are using 250 mA each one (best case scenario), you are also powering your Arduino Uno board itself (who's linear regulator is not very efficient), and thus you are reaching the limit of your USB port. In my own experience, most (non-mini) servos do take way more than just 250 mA.
Possible solutions
As a fast test, if you lack a good power source, I would do the following, which is in general a good practice when you are mixing code and electronics in a project:
Connect only one servo (let's say bicep), plus the potentiometer.
Run your program and test the servo's movements.
If it works, disconnect that servo and connect the other one.
Run and test, specially direction.
If they still jitter, try the one configuration servo with a better power supply. Be careful: most servos need 4.8V as the input voltage, so do not go over that voltage since you can damage them or significantly reduce their life time.
If you have doubts about the potentiometer itself, you can also try the one servo configuration without potentiometer at all, just hardcoding values in the servo.write() method; something like this:
void loop() {
delay(500);
Bicep.write(50);
delay(500);
Bicep.write(100);
}
That will reduce any potential problem to a software only problem, since now, according to your description, it's not clear wether you are facing an electronic configuration problem or a software bug.

Logisim gives strange error with J-K flip-flop

I have a simple circuit based on 3 J-K flip-flops, all connected to a common clock and configured identically. One of them has both J and K inputs connected to the output of the same OR gate. Logisim doesn't like this: it turns the inputs and the clock wires red, and I can't understand why.
If I disconnect just the J input, everything goes green. If I disconnect just the K input, everything stays red.
What's going on here? I can't find anything suggesting that J and K inputs can't be tied together.
I rebuilt the circuit from scratch and it works. I sent the problem file to the developer who may have a look at it, even though he is no longer actively maintaining Logisim.

Sound generator on FPGA with VHDL code

I need to use keyboard as input for musical notes, and digilent speaker as output.
I plan to use only one octave.
My most intriguing questions are:
How do I represent the musical notes in VHDL code.
How do I (or do I need to) implement a DAC module that uses Spartan 3E Starter's built-in DAC? I have read on other forums that it can't be implemented. I need to use it in order to transmit the note to the speaker. The teacher who supervises my and my colleagues' projects suggested me to look into PWM for that(but all I've found is explained in electronic manner, no accompanying code, or explanation on implementation).
Besides keyboard controller, a processing module(for returning the note corresponding to the pressed key from the notes vector) and DAC, that I have figured out so far that I need, what else do I need.
There is a DAC (see comments)
There is no DAC on the Spartan-3E Starter Kit. Using a low-pass PWM signal is a common way to generate analog signal level from digital output.
You need to define a precision for your PWM, let's say 8 bits or 256 levels. For each audio sample you want to output, you need to count from 0 to 255. When the counter is less than the desired sample level, output 1, otherwise output 0. When the counter reach 255, reset it and go to the next sample.
Thus, if you want 8 bits precision (256 levels) and 8KHz signal, the counter will have to run at 256*8000 = 2.048MHz.
For your other questions, there is no easy answer. It's your job, as designer, to figure that out.

Application of Barrel Shifter

I am doing a VLSI Project and I am implementing a Barrel Shifter using a tool called DSCH.The schematic for the same is realized using Transmission Gates.
What the circuit does is, it ROTATES the 8 bit word(8-bit shifter) with as many rotations chosen from a decoder in one clock cycle.
But I want to know the use of a rotator and why is it still called a shifter even though it's rotating.
Also please help me with some applications regarding Rotator which could be added to the present circuit to show it's use?
Rotation is just shifting with the bit exiting from one end fed back into the input at the other end, possibly by way of the carry flag bit. At the level of a simple implementation, it would make sense to have one circuit for both operations, with some additional control lines to select the source at the input side between the output of the other side, 0, or 1. Sign extension during right shift of 2's complement numbers would be another selectable option often built in.
The stackexchange sites aren't really suited to "list" questions including about applications, but a couple come to mind:
If you want a vector to test every bit of another value in turn, and to do so repeatedly, you could just keep rotating an initial one-bit-active value over an over, never having to re-initialize it.
You could swap a two-part (typically double-byte) value to imitate the opposite endieness of encoding by rotating it half way. Or putting it another way, it can be a single-operation swap of the values of two pairable but also independently accessible registers (think AL and AH together making up AX in real mode x86). But this will not work two endian swap a four-part value, such as a 32-bit value on a byte-addressable machine.
Various coding, checksum, and hashing schemes may wish to transform a value

Resources