Recent

Author Topic: How to read a resistor value with RPI?  (Read 5347 times)

Ramses

  • New Member
  • *
  • Posts: 41
Re: How to read a resistor value with RPI?
« Reply #15 on: February 06, 2021, 02:29:47 am »
/However/, if all you're trying to do is do a 1-of-4 identification it would be easier if you assumed that one end of your speaker was grounded, at which point you could have two sense wires which were either grounded or left floating in a binary pattern. That would take 2x GPIO pins set to input with pullup resistors, leaving your I2C available for other use.

yes my first tought was to use a binary system, but because i need to identify 10 differents speaker, it will take 6 wire (2 for audio, 4 for binary) so its a little too mutch. that why i tough about using resistor, but i was thinking that i ca mesure a resistor directly with my "raspberry pi 3b+" and its not the case..

the answer from  kupferstecher is very interesting, it dosent need a lot of part, but my coding ability is not very good on lazarus, and i will probably not be able to code that on lazarus

so i'm actually looking on internet to see if i can found exemple code in lazarus to use the MCP3208 or MCP3008 ( in the answer from ojz0r) , but i have not found any exemple until now..

in fact, i have no problem to buy anything that can do what i want, and with the schematic i can build almost anything in electronic, but my problem is that i am completely beginner in lazarus, the biggest problem i have is how to interface lazarus with the electronic device..

 

ojz0r

  • Jr. Member
  • **
  • Posts: 72
Re: How to read a resistor value with RPI?
« Reply #16 on: February 06, 2021, 07:19:59 am »
I recently did a setup with MCP3208 and a raspberry Pi Zero that should be compatible on the 3b as well. You can have the code if you want as an example.
It's based on the SPI example showed in the wiki here: https://wiki.lazarus.freepascal.org/Raspberry_Pi_-_SPI
I like big endians and i can not lie.

MarkMLl

  • Hero Member
  • *****
  • Posts: 8525
Re: How to read a resistor value with RPI?
« Reply #17 on: February 06, 2021, 10:23:19 am »
yes my first tought was to use a binary system, but because i need to identify 10 differents speaker, it will take 6 wire (2 for audio, 4 for binary) so its a little too mutch. that why i tough about using resistor, but i was thinking that i ca mesure a resistor directly with my "raspberry pi 3b+" and its not the case..

OK, but in that case why didn't you give us that number MUCH earlier in the discussion?

There's been a lot of work done on this sort of thing, and I'd point you at https://hackaday.com/2019/03/23/tucoplexing-a-new-charliplex-for-buttons-and-switches/ as an interesting jumping-in reference.

The above mentions an I2C expander as a possibility, which does suggest that one thing that might work for you is putting something like that next to the speaker. In any event, wire length could be a problem there but you will also need to consider that if measuring a resistor... I'm not going to start lecturing on twisted pair, four- vs two-wire measurement and so on.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

hansotten

  • Full Member
  • ***
  • Posts: 106
    • The School of Wirth
Re: How to read a resistor value with RPI?
« Reply #18 on: February 06, 2021, 10:26:40 am »
Get a cheap and small Arduino (328 pro mini, has 4 10 bit ADC, $3 in China), look up one of the many resistor measurement sketches for it, and sent the ADC value via serial to the Raspberry Pi to process with a Lazarus app. That way you avoid buying a most likely more expensive ADC hat for the Pi, safeguard the Pi for damage and have a very flexible solution.
http://pascal.hansotten.com/ Pascal for Small Machines. The School of Wirth, sources of old Pascal compilers,

MarkMLl

  • Hero Member
  • *****
  • Posts: 8525
Re: How to read a resistor value with RPI?
« Reply #19 on: February 06, 2021, 10:48:01 am »
Get a cheap and small Arduino (328 pro mini, has 4 10 bit ADC, $3 in China), look up one of the many resistor measurement sketches for it, and sent the ADC value via serial to the Raspberry Pi to process with a Lazarus app. That way you avoid buying a most likely more expensive ADC hat for the Pi, safeguard the Pi for damage and have a very flexible solution.

Good point. One of the little "DigiSPARK" boards (or strictly, a clone since the originals are discontinued) would probably do nicely subject to number of pins.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Ramses

  • New Member
  • *
  • Posts: 41
Re: How to read a resistor value with RPI?
« Reply #20 on: February 06, 2021, 02:28:23 pm »
Get a cheap and small Arduino (328 pro mini, has 4 10 bit ADC, $3 in China), look up one of the many resistor measurement sketches for it, and sent the ADC value via serial to the Raspberry Pi to process with a Lazarus app. That way you avoid buying a most likely more expensive ADC hat for the Pi, safeguard the Pi for damage and have a very flexible solution.

Yes arduino is a great idea, i'm very confortable with it because i have build many device based on arduino board in the past ( security cameras, wing generator remote controler, web browser, and many other) and i already have a lot of different arduino board here (uno, uno wifi, mega2560. etc)

So yes, i can read a resistor value with an arduino, so i think the easiest way is to use the arduino to identify the device according to the resistor value, then i can just past the device number (1 to 10, coded on 4 bit by using 4 pins) to my "raspberry pi 3 b+" (or maybe there is a better and easier solution to pass data that i dont know?)

Now, i just need to know how to read my 4 bit data with the "raspberry pi 3 b+"? (or maybe you have a better suggestion?)

ArtLogi

  • Full Member
  • ***
  • Posts: 194
Re: How to read a resistor value with RPI?
« Reply #21 on: February 07, 2021, 01:04:55 pm »
Take ie. 555 oscillator, if there is cheap IC without external parts then those or less external parts. Use different frequency for each speaker and then use Digital input channel as counter and count how many pulses you get per time unit.

Digisparks are nice if you can find them with decent price vs. Delivery time. Which is not usually the case.

If there would be analog input you could just add zener as voltage regulator and detect different voltage levels. Etc...
While Record is a drawer and method is a clerk, when both are combined to same space it forms an concept of office, which is alias for a great suffering.

dseligo

  • Hero Member
  • *****
  • Posts: 1651
Re: How to read a resistor value with RPI?
« Reply #22 on: February 07, 2021, 02:25:52 pm »
Now, i just need to know how to read my 4 bit data with the "raspberry pi 3 b+"? (or maybe you have a better suggestion?)
You can find example here: https://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#Reading_the_status_of_a_pin.

hansotten

  • Full Member
  • ***
  • Posts: 106
    • The School of Wirth
Re: How to read a resistor value with RPI?
« Reply #23 on: February 15, 2021, 11:28:37 am »
Get a cheap and small Arduino (328 pro mini, has 4 10 bit ADC, $3 in China), look up one of the many resistor measurement sketches for it, and sent the ADC value via serial to the Raspberry Pi to process with a Lazarus app. That way you avoid buying a most likely more expensive ADC hat for the Pi, safeguard the Pi for damage and have a very flexible solution.

Yes arduino is a great idea, i'm very confortable with it because i have build many device based on arduino board in the past ( security cameras, wing generator remote controler, web browser, and many other) and i already have a lot of different arduino board here (uno, uno wifi, mega2560. etc)

So yes, i can read a resistor value with an arduino, so i think the easiest way is to use the arduino to identify the device according to the resistor value, then i can just past the device number (1 to 10, coded on 4 bit by using 4 pins) to my "raspberry pi 3 b+" (or maybe there is a better and easier solution to pass data that i dont know?)

Now, i just need to know how to read my 4 bit data with the "raspberry pi 3 b+"? (or maybe you have a better suggestion?)

Send to Serial, lazserial on the Raspberry side to read.
http://pascal.hansotten.com/ Pascal for Small Machines. The School of Wirth, sources of old Pascal compilers,

 

TinyPortal © 2005-2018