- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
-
They are all 24-bit data(or multiples of) with a clock and data on positive or negative edge triggering
-
There is a gap between data packets that is orders of magnitude greater than the clock to distinguish start.
Solved! Go to Solution.
- Labels:
-
PSOC5 LP MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Attached is a DigiMatic Receiver project. It should be very close to match the specs and timing of the Chinese scales link you provided.
Since I don't have a DigiMatic device (which transmits), I added a DigiMatic Tx simulator.
I also provided a UART debugging comm port to display the returned values from the DigiMatic Rx.
This should be a good starting point.
CORRECTION!!!
A closer inspection of the links you provided requires me to issue a correction.
The attached project is called DigiMatic however it is more accurate to say the protocol support within is the Chinese Scale protocol.
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
I'd like to try to help. However your description as a bit confusing.
What is your INPUT to the PSoC? Serial? UART, SPI or I2C type? Parallel (24-bit)?
What is your desired output from the PSoC? Serial? UART, SPI or I2C type? Parallel (24-bit)? Other?
In your description you reference a 24-bit shift register. I'm confused as to why a shift register is necessary.
For example if you need to output 24bits of serial data, you can use the CPU to dump 8-bits a time (3 times).
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Len, Sorry for causing any confusion. Many forums don't like direct links to other sites , so I did suggest where to go to find further information on these scales, as there are a variety of variations on them, and they explain much better than I can. But its basically a two wire stream with a clock and data in, very much like SPI in, but you need to qualify a new data packet from the dead period in between.
So I need to capture the 24 bit serial stream and collect it as a 24 bit 'word' for subsequent processing and output to a device be that serial or LCD.
It is a trivial task with a small micro (eg pic12 -18 or atmel etc) to do one channel either using interrupts or simply reading and analysing each bit (clock is usually only 10's of kilohertz, but becomes much trickier in the CPU if you have 4+ all happening asynchronously, I tried it with an ESP32 with 4 channels, but it wasn't reliable, and it struck me that a psoc doing this in hardware would be much easier (IF you know how to do it!!)
I trust this clears the confusion, and look forward to your suggestions
Thanks
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Please include at least one link to your external site for the protocol you are trying to implement.
In advance of this information, I have attached an example project that may be useful to you.
This project uses the CPU to only load the next 24-bits into a SPI component. The SPI provides the 2-wire CLOCK and DATA.
It also incorporates a timer to provide the inter-packet timeout between 24-bit transfers.
To prove this HW circuit transfers data only when data is available, I placed a task flag to only transfer the 24-bit data for 1 second, wait for 1 second and start transferring data again.
The beauty of this technique is that the CPU is used very minimally. The PSoC HW is tuned to do most of the work.
The CPU only used to push the 24-bit data into the SPI 4-byte FIFO.
The SPI HW transfers the 24-bits (3-bytes) to the 2-wire bus. Once this is 'DONE', it triggers a Timer to time out the inter-packet delay.
Once the delay is completed, an ISR is run to transfer the next 24-bit value if available.
In theory, it is possible to use DMA to further minimize CPU overhead. I thought is was simpler to understand what was happening with an ISR instead.
Not knowing the protocol you are trying to implement, I assigned the Clock-edge-to-data, Clock rate, inter-packet delay values.
Note: If you need multiple channels, I was able to create 6 of these circuits before getting the Resource exceeded error.
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Len,
That certainly looks on the right lines. I'll check it out as soon as I can and get back to you.
Here is one link to a type of scale, as I said there are many more, but this explains the principle
http://shumatech.com/support/chinese_scales.htm
Once again, many thanks
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Thanks for the link. It answers some of the questions.
The project I attached earlier is for the PSoC to OUTPUT (Tx) the DigiMatic protocol. Not to receive the DigiMatic protocol. I now realize that you what to INPUT (Rx) the protocol.
This project is usefully for Simulating the DigiMatic Protocol from a sensor device.
Hold tight. I'm in the process to create a DigiMatic Rx device for the PSoC.
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thats brilliant thank you,
A bit more info on some of the other scales out there
https://www.yuriystoys.com/search/label/Digital%20Scales%20and%20Calipers
You have to go through a few blogs to get it all.
Its a bit different to the Mitutoyo ( which would also be good to have.)
Looking forward to your answer.
Thanks
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Attached is a DigiMatic Receiver project. It should be very close to match the specs and timing of the Chinese scales link you provided.
Since I don't have a DigiMatic device (which transmits), I added a DigiMatic Tx simulator.
I also provided a UART debugging comm port to display the returned values from the DigiMatic Rx.
This should be a good starting point.
CORRECTION!!!
A closer inspection of the links you provided requires me to issue a correction.
The attached project is called DigiMatic however it is more accurate to say the protocol support within is the Chinese Scale protocol.
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wow, thats fantastic !!
Thanks Len.
I will try connecting to my hardware , probably over the weekend and let you know how I get on.
It did issue one warning which I will investigate, it may be nothing
Warning-1367: Hold time violation found in a path from clock ( Clock_1 ) to clock ( dm_clk/q
Thanks so much. Let you know how I get on.
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
You're welcome.
I got the warning too. However the data from the Tx stimulus was Rx'd correctly.
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Based on the Chinese Scales link you provide, how does someone connect to the PCB traces for the signals? They're not 0.1 inch pitch.
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Len,
In answer to your question , not easily!!! They did at one time supply cables that plugged in, but it was useless. The only real answer is to solder them in, then pot them. I saw someone trying to 3d print one, but I wouldn't rely on it. A MUCH better alternative is the SHAHE scale such as
This uses a mini USB connector, but that is none standard pinout to avoid damage if you plug one in to a USB port.
All of this is explained in
https://www.yuriystoys.com/2019/01/shahe-dro-scales.html
but you have to search around for the data. This is the unit I am specifically trying to target. And here's some oscilloscope grabs
As you can see its pretty darn slow. The data period is approximately 10mS and the gap Around a 100mS. These signals are being fed in to your code as (blue)clock and (yellow) data. I did run your software, and it seemed to work with your simulated data, however that was running around a 1,000 times faster, with timing in uS rather than mS from my scale. I did try increasing the PWM time, but no luck. I removed all of your generator components. I was thinking of doing a simple pin read to get to the end of the first 24 bits of data, and then start the SPI. It should stay in synch after that!!
Any ideas?
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
I have a Harbor Freight Caliper with the 4-pin connection.
You should be able to change the timing parameters on my program pretty easily.
You need to determine the incoming CLK. It appears from the scope plots to be 3KHz. Then change Clock_2 to CLK*2 which would be 6KHz.
Then adjust the PWM_1 period to allow a maximum 30ms between terminal counts (tc). That would set the period to 200.
It appears from the scope plot that there is only one 24-bit data from your sensor. Therefor you can leave the compare alone. Just use rx_data[0].
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Do me a favor.
Capture two data packets of the Clock and Data signals on the scope and send me the .csv results.
With the .csv file of these signals, I can try to replicate your data input with a signal generator into your project.
"Engineering is an Art. The Art of Compromise."