Skip to content

Commit a619161

Browse files
authored
Merge branch 'master' into prepare-for-main-rename
2 parents de99525 + f59be45 commit a619161

File tree

6 files changed

+323
-21
lines changed

6 files changed

+323
-21
lines changed

.eleventy.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ module.exports = function(eleventyConfig) {
119119
});
120120

121121
// Liquid filter to convert a date to a string
122-
eleventyConfig.addLiquidFilter("date_to_string", date => date.toString() );
122+
eleventyConfig.addLiquidFilter("to_utc_string", date => date.toUTCString() );
123123

124124
// Liquid filter for long date string
125125
eleventyConfig.addLiquidFilter("date_to_long_string", function(date) {
@@ -140,6 +140,9 @@ module.exports = function(eleventyConfig) {
140140
eleventyConfig.addGlobalData("site_title", () => getDataFromConfigYaml("title"));
141141
eleventyConfig.addGlobalData("site_tagline", () => getDataFromConfigYaml("tagline"));
142142
eleventyConfig.addGlobalData("production_url", () => getDataFromConfigYaml("production_url"));
143+
eleventyConfig.addGlobalData("JB", () => getDataFromConfigYaml("JB"));
144+
eleventyConfig.addGlobalData("author", () => getDataFromConfigYaml("author"));
145+
eleventyConfig.addGlobalData("now" , () => new Date());
143146

144147
eleventyConfig.addNunjucksFilter("date", function(date, format) {
145148
return moment(date).format(format);

_includes/layouts/common.liquid

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ theme:
5050
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/9000.0.1/themes/prism.min.css" rel="stylesheet" />
5151

5252
<!-- atom & rss feed -->
53-
<link href="{{ BASE_PATH }}{{ site.JB.atom_path }}" type="application/atom+xml" rel="alternate" title="Sitewide ATOM Feed">
54-
<link href="{{ BASE_PATH }}{{ site.JB.rss_path }}" type="application/rss+xml" rel="alternate" title="Sitewide RSS Feed">
53+
<link href="{{ BASE_PATH }}{{ JB.atom_path }}" type="application/atom+xml" rel="alternate" title="Sitewide ATOM Feed">
54+
<link href="{{ BASE_PATH }}{{ JB.rss_path }}" type="application/rss+xml" rel="alternate" title="Sitewide RSS Feed">
5555
</head>
5656
<body class="template">
5757
<div class="container">
340 KB
Loading

content/2024/10/20-micromouse-sensors/graphs.svg

Lines changed: 194 additions & 0 deletions
Loading
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
title: Phototransistor Sensors for Micromouse UK
3+
layout: post
4+
date: 2024-10-20
5+
tags: [micromouse, sensors, phototransistor, electronics]
6+
---
7+
My student is making an entry for the [UK Micromouse](https://ukmars.org) competition. The competition has a recommended reference robot design for entrants to build, the [UKMarsBot](https://ukmars.org/projects/ukmarsbot/). She applied, and was sent the Main board along with the Line sensor and Wall sensor boards.
8+
9+
She's been building the UKMarsBot, with me giving some guidance and help. This has meant practising her soldering skills, and reading the circuit. The decisions made so far:
10+
11+
- Using the Cytron Maker Nano instead of the Arduino Nano. This has some RGB LED's, a user button and the more powerful RP2040, but runs on 3.3v and requires a few modifications in the assembly of the main board. Importantly - notching out the 5v supply pin from the Nano's regulator, and bridging the 3.3v supply to the 5v supply pin so the boards devices are at 3.3v levels. This ensure that the sensors output at 3,3v levels and don't damage the RP2040. We read the [main board schematic](https://ukmars.org/projects/ukmarsbot/reference-guide/main-board-reference/) to see how the power supply was connected to understand this.
12+
- Putting the motor board, a TB6612FNG, on female sockets. This caused it to be too close to the Maker Nano, so we had to add some extra headers to raise the maker nano up a bit. However, this meant we also had fewer concerns about the USB cable and capacitors bothering each other.
13+
14+
She has been asking her parents to buy parts as she reaches different stages of assembly. We've come to building the sensors.
15+
16+
## UKMarsBot Sensors
17+
18+
There are a few sensors on this robot:
19+
20+
- The motors may have encoders
21+
- A detachable line following sensor board
22+
- A detachable wall sensor board
23+
24+
The line sensor board has 4 phototransistors to detect the brightness under them, and the wall sensor board uses 3 to detect reflected intensity as a proxy for distance.
25+
26+
Each has 2 ways to build them, with visible light, or with infrared light. When ordering parts, it's generally a good idea to order more of 1 part, than a few different ones. However, their question is if they could use the same phototransistors for both sensors.
27+
28+
## Investigating phototransistors
29+
30+
A quick recap on these devices. Effectively the phototransistor is an electronic gate that lets more current through when light shines on it. By measuring how much current gets through, you can measure light levels.
31+
32+
This can be used with a resistor, to pull down or pull up the voltage level for a logic threshold, or as a voltage divider that could be measured by an analog input (ADC). In these sensors, they are both used as voltage dividers.
33+
34+
Let's compare these sensor boards, and how their use cases differ:
35+
36+
sensor | resistor side | visible light | IR Light
37+
--- | --- | --- | ---
38+
line sensor | high | VISHAY BPW85C | OSRAM SFH309FA
39+
wall sensor | low | VISHAY BPW85C | VISHAY BPW85C
40+
41+
There were other possible parts, but notice that the VISHAY BPW85C is used for 3 out of 4 use cases. Why is it different for the line sensor with IR light?
42+
43+
## Comparing the parts
44+
45+
The next thing we did was look at the datasheets for the parts. The datasheet links:
46+
47+
- [VISHAY BPW85C](https://www.vishay.com/docs/81531/bpw85a.pdf) - note it has the A, B and C parts.
48+
- [OSRAM SFH309FA](https://look.ams-osram.com/m/ce14b97f1982f0f/original/SFH-309-FA.pdf)
49+
50+
We started with some basics on these parts. The IR emitters are around 950nm.
51+
52+
Model number | VISHAY BPW85C | OSRAM SFH309FA | Notes
53+
--- | --- | --- | ---
54+
Type | NPN Phototransistor | NPN Phototransistor | The Same
55+
Package | T1 - 3mm | T1 - 3mm | The Same
56+
Wavelength sensitivity (nm) | 450-1080 | 730-1120 | The emitters are in this wave-length
57+
Mac sensitivity (nm) | 850 | 900 | The OSRAM is closer to the IR emitter
58+
Dark current (nA) | 1-200 | 0-1 | The OSRAM has lower dark current
59+
Collector-emitter voltage Max (V) | 70 | 35 | Both will be fine for 3.3v
60+
Angle half dark (degrees) | +/- 25 | +/- 12 | The OSRAM is more focused
61+
Cost per part for 5 to 10 | £0.641 | £0.468 | The OSRAM is cheaper. Comparison made at Farnell Uk, ex VAT and postage
62+
63+
Note that both also have a minimum order quantity of 5.
64+
65+
So far, the OSRAM device is more sensitive. It's more focus with a narrower angle, which might make it more useful for the line sensor. For the wall sensor, a wider angle might be more useful. However, they are otherwise equivalent with these. Some heat-shrink could be used to narrow the angle of the VISHAY part.
66+
67+
At this point, my student needed to leave, however, I carried on investigating so I could send them the results.
68+
69+
## Comparing the graphs
70+
71+
The stats above say nothing about how the device responds to light in terms of current. The guide for the UKMarsBot suggested different resistors to load the different phototransistor types. Perhaps looking at their response graphs would give a better idea of how they differ.
72+
73+
This [Digikey guide](https://www.digikey.com/en/articles/the-basics-of-photodiodes-and-phototransistors-and-how-to-apply-them?msockid=2512d95c6edb65363993cdcf6f3b6440) has some notes on how to read the graphs.
74+
75+
Let's see the graphs for the two devices:
76+
77+
![Sensor Graphs](/2024/10/20-micromouse-sensors/graphs.svg)
78+
79+
These graphs show the current through the phototransistor versus the collector-emitter voltage for different light levels.
80+
81+
These are a little awkward to compare. The OSRAM graph on the left has a linear X scale for Vce vs a log scale for current. The VISHAY graph on the right has a log scale for Vce vs a log scale for current. We are at 3.3v, so I've drawn in red dashed line roughly where I think 3.3v is at on each. This is a bit easier to place on the VISHAY graph.
82+
83+
I can then trace this up, and draw some lines for the light levels across to the current axis. I've drawn these in green, blue and yellow. I'll ignore the additional 0.05 mW/cm^2 line on the VISHAY graph, as it's not on the OSRAM graph. I'll ignore the 0.25 and 0.2 measurements that are different. Leaving us 3 to compare.
84+
85+
I've then tried to roughly interpret the log current graph. Note that the current scale for both is mA (milliamps). On the OSRAM graph the lower bound is 10^-1, or 0.1. ON the VISHAY graph, the lower bound is 10^-2, or 0.01. the upper bounds of the current axes on both are the same though.
86+
87+
Once the numbers are drawn in, these characteristics are pretty much the same, perhaps with some error on my part interpreting the log scale.
88+
89+
## Next steps
90+
91+
The parts look the same, other than cost and angle, even down to the resistor choice for them. Although I note that in the building guide it suggests 2k to 4k7 for the line sensor pull ups, and 1k or 1.8k for the wall sensor pull downs.
92+
93+
The one thing that gives me pause in recommending the cheaper OSRAM part for both sensors is the angle. The BPW85C is a bit pricier, but it's more likely to be useful for both sensors, and in use for the visible light line sensor.
94+
95+
I'll send this to my student, and see what they think. I think for the resistors, we can do some breadboard experiments to see how the photodiodes respond to different light levels. This will help us understand the sensors better.
96+
97+
The simpler answer though is to use visible light and the VISHAY BPW85C for both sensors. This will make ordering easier, and the sensors more interchangeable.

navigation_and_indexes/rss.liquid

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
---
22
title : RSS Feed
33
permalink: /rss.xml
4+
theme:
5+
name: orionrobots
46
---
7+
{%- capture BASE_PATH %}{{ site.production_url }}{% endcapture -%}
8+
{% capture ASSET_PATH %}{{ BASE_PATH }}/assets/themes/{{ theme.name }}{% endcapture -%}
59
<?xml version="1.0" encoding="UTF-8" ?>
610
<rss version="2.0">
711
<channel>
8-
<title>{{ site.title }}</title>
9-
<description>{{ site.title }} - {{ site.author.name }}</description>
10-
<link>{{ site.production_url }}{{ site.rss_path }}</link>
11-
<link>{{ site.production_url }}</link>
12-
<lastBuildDate>{{ site.time }}</lastBuildDate>
13-
<pubDate>{{ site.time }}</pubDate>
14-
<ttl>1800</ttl>
15-
16-
{% for post in site.posts %}
17-
<item>
18-
<title>{{ post.title }}</title>
19-
<description>{{ post | excerpt }}</description>
20-
<link>{{ site.production_url }}{{ post.url }}</link>
21-
<guid>{{ site.production_url }}{{ post.id }}</guid>
22-
<pubDate>{{ post.date }}</pubDate>
23-
</item>
24-
{% endfor %}
25-
12+
<title>{{ site.title }}</title>
13+
<description>{{ site.title }} - {{ site.tagline }}</description>
14+
<link>{{ site.production_url }}</link>
15+
<language>en-gb</language>
16+
<lastBuildDate>{{ now | to_utc_string }}</lastBuildDate>
17+
<pubDate>{{ now | to_utc_string }}</pubDate>
18+
<ttl>1800</ttl>
19+
<image>
20+
<url>{{ ASSET_PATH }}/images/social-banner.jpg</url>
21+
<title>{{ site.title }}</title>
22+
<link>{{ site.production_url }}</link>
23+
</image>
24+
{%- assign posts = collections.all | reverse | with_explicit_date -%}
25+
{%- for post in posts -%}
26+
<item>
27+
<title>{{ post.data.title }}</title>
28+
<description>{{ post | excerpt | strip_html }}</description>
29+
<link>{{ site.production_url }}{{ post.url }}</link>
30+
<guid>{{ site.production_url }}{{ post.url }}</guid>
31+
<pubDate>{{ post.date | to_utc_string }}</pubDate>
32+
</item>
33+
{%- endfor -%}
2634
</channel>
2735
</rss>

0 commit comments

Comments
 (0)